summaryrefslogtreecommitdiff
path: root/chapter18/src/test/java/com
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2025-01-07 16:38:11 -0800
committerCliff Click <cliffc@acm.org>2025-01-15 15:07:30 -0800
commitdd67005904ab8f93bacd595290159b20d10f75a5 (patch)
treed81fb0e2aadc3342bcd27ce8bb7824addb0e3fe5 /chapter18/src/test/java/com
parente493d4b83d638db6a9305525925a4052739b6572 (diff)
downloadSimple-dd67005904ab8f93bacd595290159b20d10f75a5.tar.gz
Simple-dd67005904ab8f93bacd595290159b20d10f75a5.zip
Promote outside of constructors
Var picks up a Real(tm) isFRef flag. Minor progress bug.
Diffstat (limited to 'chapter18/src/test/java/com')
-rw-r--r--chapter18/src/test/java/com/seaofnodes/simple/Chapter18Test.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/chapter18/src/test/java/com/seaofnodes/simple/Chapter18Test.java b/chapter18/src/test/java/com/seaofnodes/simple/Chapter18Test.java
index 9e74ce6d..39edb352 100644
--- a/chapter18/src/test/java/com/seaofnodes/simple/Chapter18Test.java
+++ b/chapter18/src/test/java/com/seaofnodes/simple/Chapter18Test.java
@@ -225,6 +225,26 @@ return f();
catch( Exception e ) { assertEquals("Expecting 2 arguments, but found 0",e.getMessage()); }
}
+
+ @Test
+ public void testErr4() {
+ CodeGen code = new CodeGen(
+"""
+struct S {
+ {int} f = { -> x(); return 0; }; // Do not let fref x be a field
+};
+val x = { -> return 1; };
+S? s = null;
+for(;;) {
+ if (s) return s.x;
+}
+""");
+ try { code.parse().opto().typeCheck(); fail(); }
+ catch( Exception e ) { assertEquals("Accessing unknown field 'x' from '*S'",e.getMessage()); }
+ }
+
+
+
// Mutual recursion. Fails without SCCP to lift the recursive return types.
@Ignore @Test
public void testFcnMutRec() {