]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
(refs #7571) Fixed incorrect handling of effects in edo 39/1139/1
authorHannu Niemistö <hannu.niemisto@semantum.fi>
Mon, 23 Oct 2017 16:05:30 +0000 (19:05 +0300)
committerHannu Niemistö <hannu.niemisto@semantum.fi>
Mon, 23 Oct 2017 16:05:30 +0000 (19:05 +0300)
Change-Id: I6ba1b4d8690a726d08abf4be62309b51555f9743

bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EBind.java
tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/ModuleRegressionTests.java
tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/MonadSyntax6.scl [new file with mode: 0644]

index 84cc220c1a0222e75def8781fe657eaff1a88aa3..af31cf9c200c5286f8c0737991807c5dfa0344d3 100644 (file)
@@ -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();
index 0e06e61e3ef57d4704abbbfa8803829c1e4df22d..6e11e24a416dbd00e3ecc33e0e6ed24c8e3ba201 100644 (file)
@@ -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 (file)
index 0000000..58ae542
--- /dev/null
@@ -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