From 1a70d6085093907f2120e5319554420b1ada614a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Hannu=20Niemist=C3=B6?= Date: Wed, 2 Aug 2017 12:36:35 +0300 Subject: [PATCH] Fixed an error with recursive definition that is not exported or used refs #7402 Change-Id: Ic0a6263df965117eab72f1495dfdafb68135ce9d --- .../codegen/ssa/statements/LetApply.java | 2 ++ ...ryLeakTest.java => MemoryLeakExperiment.java} | 2 +- .../compiler/tests/ModuleRegressionTests.java | 3 ++- .../scl/compiler/tests/scl/RecursionBug.scl | 16 ++++++++++++++++ 4 files changed, 21 insertions(+), 2 deletions(-) rename tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/{MemoryLeakTest.java => MemoryLeakExperiment.java} (98%) create mode 100644 tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/RecursionBug.scl 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 -- 2.47.1