From 3617495d8efbcce23bbc9f1754c7d27d34d30a52 Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Mon, 19 Oct 2026 11:48:37 -0700 Subject: Fix a missed int-widening around recursion --- .../src/test/java/com/seaofnodes/simple/Chapter24Test.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'chapter24/src/test/java') diff --git a/chapter24/src/test/java/com/seaofnodes/simple/Chapter24Test.java b/chapter24/src/test/java/com/seaofnodes/simple/Chapter24Test.java index 8cd300c2..3e5dc2a9 100644 --- a/chapter24/src/test/java/com/seaofnodes/simple/Chapter24Test.java +++ b/chapter24/src/test/java/com/seaofnodes/simple/Chapter24Test.java @@ -17,6 +17,20 @@ import org.junit.Test; import static org.junit.Assert.*; public class Chapter24Test { + @Test public void testRecursiveWidening() { + String[] srcs = { + // Parm(x) must widen even though the recursive result is constant. + "val f = { int x, int limit -> x >= limit ? 0 : f(x+1,limit); }; return f(0,arg);", + // The growing result has its own cycle, which never crosses Parm(x). + "val f = { int x -> x <= 0 ? 0 : f(x-1)+1; }; return f(3);" + }; + for( int i=0; i