From 1cb8ccadc93ab1a1ac5981ea6634b3ef5dd27ec4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Hannu=20Niemist=C3=B6?= Date: Mon, 23 Oct 2017 19:05:30 +0300 Subject: [PATCH] (refs #7571) Fixed incorrect handling of effects in edo Change-Id: I6ba1b4d8690a726d08abf4be62309b51555f9743 --- .../compiler/elaboration/expressions/EBind.java | 4 +++- .../scl/compiler/tests/ModuleRegressionTests.java | 1 + .../scl/compiler/tests/scl/MonadSyntax6.scl | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/MonadSyntax6.scl diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EBind.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EBind.java index 84cc220c1..af31cf9c2 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EBind.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EBind.java @@ -79,8 +79,10 @@ public class EBind extends SimplifiableExpression { if(edo) context.pushEffectUpperBound(location, blockType == BlockType.Monad ? Types.NO_EFFECTS : Types.metaVar(Kinds.EFFECT)); in = in.checkType(context, requiredType); - if(edo) + if(edo) { effect = context.popEffectUpperBound(); + context.declareEffect(location, effect); + } else effect = Types.NO_EFFECTS; Type inType = in.getType(); diff --git a/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/ModuleRegressionTests.java b/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/ModuleRegressionTests.java index 0e06e61e3..6e11e24a4 100644 --- a/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/ModuleRegressionTests.java +++ b/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/ModuleRegressionTests.java @@ -185,6 +185,7 @@ public class ModuleRegressionTests extends TestBase { @Test public void MonadSyntax3() { test(); } @Test public void MonadSyntax4() { test(); } @Test public void MonadSyntax5() { test(); } + @Test public void MonadSyntax6() { test(); } @Test public void NoDefinitionErrorMessage() { test(); } @Test public void NoInstance() { test(); } @Test public void NoInstance2() { test(); } diff --git a/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/MonadSyntax6.scl b/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/MonadSyntax6.scl new file mode 100644 index 000000000..58ae542ff --- /dev/null +++ b/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/MonadSyntax6.scl @@ -0,0 +1,14 @@ +module { + features = [edo] +} + +import "StandardLibrary" + +example :: () -> Maybe Integer +example _ = edo + str <- Just "a" + let print str in Nothing + +main = example () +-- +10:9-10:18: Side-effect Proc is forbidden here. \ No newline at end of file -- 2.47.1