(refs #7621) Fixed handling of $ in application ignoring return value 27/1227/2
authorHannu Niemistö <hannu.niemisto@semantum.fi>
Wed, 15 Nov 2017 11:20:41 +0000 (13:20 +0200)
committerHannu Niemistö <hannu.niemisto@semantum.fi>
Wed, 15 Nov 2017 11:51:38 +0000 (13:51 +0200)
Change-Id: Id605cb22cb195d353970cc5ce8c45eecc2428841

bundles/org.simantics.modeling/scl/Simantics/Query.scl
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EApply.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/IfBranchesWithDifferentTypes.scl [new file with mode: 0644]

index d2809ff65d51219dd8a15c4f1cb3ea1fd0347988..7e0aeb77b647bda42bcd83d5c5aa5769b4a8869f 100644 (file)
@@ -37,7 +37,7 @@ createSCLQueryType library name = do
     queryType = newResource ()
     claim queryType L0.Inherits MOD.SCLQuery
     claimRelatedValue queryType L0.HasName name
-    claimAssertion MOD.SCLQuery.values $ createSCLValueIndependent MOD.SCLQuery.Value "[]"
+    claimAssertion queryType MOD.SCLQuery.values $ createSCLValueIndependent MOD.SCLQuery.Value "[]"
     claim queryType L0.PartOf library
     addCommentMetadata ("Created SCL Query Type " + name)
     queryType
index 02c7dff4585c95e0d55d7bf485266f90327b31e6..5d915a98dce93b2ac88e2476effaed460e2d25ba 100644 (file)
@@ -265,7 +265,7 @@ public class EApply extends Expression {
     @Override
     public Expression checkIgnoredType(TypingContext context) {
         if(parameters.length == 2 && function instanceof EConstant && ((EConstant)function).value.getName() == Names.Prelude_dollar)
-            return new EApply(location, parameters[0], parameters[1]).inferType(context);
+            return new EApply(location, parameters[0], parameters[1]).checkIgnoredType(context);
         inferType(context, true);
         if(Types.canonical(getType()) != Types.UNIT)
             return new ESimpleLet(location, null, this, new ELiteral(NoRepConstant.PUNIT));
index e6eb2b5afe5eb2eb5b329131e339fad4a6d34550..00af273c71d8c1295e70e61a9b0e13b9b4d6c09b 100644 (file)
@@ -100,6 +100,7 @@ public class ModuleRegressionTests extends TestBase {
     @Test public void Guards1() { test(); }
     @Test public void Guards2() { test(); }
     @Test public void IdAsOperator() { test(); }
+    @Test public void IfBranchesWithDifferentTypes() { test(); }
     //@Test public void IfWithoutElse() { test(); }
     @Test public void IllegalChar() { test(); }
     @Test public void ImportJavaConstructor() { test(); }
diff --git a/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/IfBranchesWithDifferentTypes.scl b/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/IfBranchesWithDifferentTypes.scl
new file mode 100644 (file)
index 0000000..97ce61f
--- /dev/null
@@ -0,0 +1,15 @@
+import "StandardLibrary"
+
+find a = a
+foo x = True
+
+main = iter (\x -> do
+    if x == "A"
+    then foo $ find 23
+    else ()
+    ()
+  ) ["x"]
+ where
+  set = MSet.create () 
+--
+()
\ No newline at end of file