From dd67005904ab8f93bacd595290159b20d10f75a5 Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Tue, 7 Jan 2025 16:38:11 -0800 Subject: Promote outside of constructors Var picks up a Real(tm) isFRef flag. Minor progress bug. --- .../java/com/seaofnodes/simple/Chapter18Test.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'chapter18/src/test/java/com') 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() { -- cgit v1.2.3