From: Hannu Niemistö Date: Wed, 15 Nov 2017 11:20:41 +0000 (+0200) Subject: (refs #7621) Fixed handling of $ in application ignoring return value X-Git-Tag: v1.31.0~33^2 X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=commitdiff_plain;h=52b3c02e20d817f124f9024bd3f40518d19cbe94 (refs #7621) Fixed handling of $ in application ignoring return value Change-Id: Id605cb22cb195d353970cc5ce8c45eecc2428841 --- diff --git a/bundles/org.simantics.modeling/scl/Simantics/Query.scl b/bundles/org.simantics.modeling/scl/Simantics/Query.scl index d2809ff65..7e0aeb77b 100644 --- a/bundles/org.simantics.modeling/scl/Simantics/Query.scl +++ b/bundles/org.simantics.modeling/scl/Simantics/Query.scl @@ -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 diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EApply.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EApply.java index 02c7dff45..5d915a98d 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EApply.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EApply.java @@ -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)); 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 e6eb2b5af..00af273c7 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 @@ -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 index 000000000..97ce61f96 --- /dev/null +++ b/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/IfBranchesWithDifferentTypes.scl @@ -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