From: Hannu Niemistö Date: Wed, 2 Aug 2017 09:36:35 +0000 (+0300) Subject: Fixed an error with recursive definition that is not exported or used X-Git-Tag: v1.31.0~264^2~10 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F93%2F793%2F1;p=simantics%2Fplatform.git Fixed an error with recursive definition that is not exported or used refs #7402 Change-Id: Ic0a6263df965117eab72f1495dfdafb68135ce9d --- diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/ssa/statements/LetApply.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/ssa/statements/LetApply.java index d9d79737f..210e3ded3 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/ssa/statements/LetApply.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/ssa/statements/LetApply.java @@ -356,6 +356,8 @@ public class LetApply extends LetStatement implements ValRefBinder { SSABlock headBlock = getParent(); SSAFunction thisFunction = headBlock.getParent(); + if(thisFunction == function) + return; /*System.out.println("--- INLINING -------------------------------"); System.out.println(thisFunction); diff --git a/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/MemoryLeakTest.java b/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/MemoryLeakExperiment.java similarity index 98% rename from tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/MemoryLeakTest.java rename to tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/MemoryLeakExperiment.java index 7ff61a83e..76cd51e90 100644 --- a/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/MemoryLeakTest.java +++ b/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/MemoryLeakExperiment.java @@ -14,7 +14,7 @@ import org.simantics.scl.compiler.top.SCLExpressionCompilationException; import org.simantics.scl.compiler.types.Type; import org.simantics.scl.compiler.types.Types; -public class MemoryLeakTest { +public class MemoryLeakExperiment { ModuleRepository moduleRepository; EnvironmentSpecification environmentSpecification; 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 aa3b764e8..39b53b8b5 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 @@ -207,13 +207,14 @@ public class ModuleRegressionTests extends TestBase { @Test public void Record1() { test(); } @Test public void Record2() { test(); } @Test public void RecordShorthand() { test(); } + @Test public void RecursionBug() { test(); } @Test public void RecursiveContext() { test(); } @Test public void RecursiveValues2() { test(); } @Test public void RecursiveValues3() { test(); } @Test public void RecursiveValues4() { test(); } @Test public void RedBlackTrees() { test(); } @Test public void Relations1() { test(); } - @Test public void Relations2() { test(); } + @Test public void Relations2() { test(); } @Test public void RepeatedVariableInPattern() { test(); } @Test public void Scanl() { test(); } @Test public void Search() { test(); } diff --git a/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/RecursionBug.scl b/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/RecursionBug.scl new file mode 100644 index 000000000..3a6ab2482 --- /dev/null +++ b/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/RecursionBug.scl @@ -0,0 +1,16 @@ +module { + export = [main] +} + +import "Prelude" + +data Path = EmptyPath | ConsPath String Path + +showR :: Path -> String +showR EmptyPath = "@" +showR (ConsPath h EmptyPath) = h +showR (ConsPath h t) = "\(h)-\(showR t)" + +main = "Hello world!" +-- +Hello world! \ No newline at end of file