Fixed an error with recursive definition that is not exported or used 93/793/1
authorHannu Niemistö <hannu.niemisto@semantum.fi>
Wed, 2 Aug 2017 09:36:35 +0000 (12:36 +0300)
committerHannu Niemistö <hannu.niemisto@semantum.fi>
Wed, 2 Aug 2017 09:36:35 +0000 (12:36 +0300)
refs #7402

Change-Id: Ic0a6263df965117eab72f1495dfdafb68135ce9d

bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/ssa/statements/LetApply.java
tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/MemoryLeakExperiment.java [moved from tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/MemoryLeakTest.java with 98% similarity]
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/RecursionBug.scl [new file with mode: 0644]

index d9d79737f5222ab39e475a6385377eef49f8f0ce..210e3ded3243fc20755dd4553dd19bd309f0d0ba 100644 (file)
@@ -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);
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 7ff61a83e8bf597f1319c062749d77922fcfebcd..76cd51e900923c88917cd61d2ac1dde235f72646 100644 (file)
@@ -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;
index aa3b764e860bef4fd05814c6e162553e111eda03..39b53b8b548476e673a657728e250d318c45ec73 100644 (file)
@@ -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 (file)
index 0000000..3a6ab24
--- /dev/null
@@ -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