Skip to content

Commit 861f5da

Browse files
committed
Actually test the stack size problem.
The test was minimized too far and did not actually have a stack size issue. Also added a test when in a local `def` and made the comment for the `lazy val` case more accurate.
1 parent 38923f9 commit 861f5da

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

tests/run/break-opt.scala

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,27 @@ object breakOpt:
5858
y
5959

6060
def test7(x0: Int): Option[Int] =
61-
boundary:
62-
Some(
63-
if x0 < 0 then break(None) // no jump possible, since stacksize changes
64-
else x0 + 1
65-
)
66-
61+
val result =
62+
boundary:
63+
Some(
64+
1 + (
65+
if x0 < 0 then break(None) // no jump possible, since stacksize changes and no direct RETURN
66+
else x0
67+
)
68+
)
69+
result.map(_ + 10)
6770

6871
def test8(x0: Int): Option[Int] =
6972
boundary:
7073
lazy val x =
71-
if x0 < 0 then break(None) // no jump possible, since stacksize changes
74+
if x0 < 0 then break(None) // no jump possible, since ultimately in a different method
75+
else x0 + 1
76+
Some(x)
77+
78+
def test9(x0: Int): Option[Int] =
79+
boundary:
80+
def x =
81+
if x0 < 0 then break(None) // no jump possible, since in a different method
7282
else x0 + 1
7383
Some(x)
7484

@@ -83,7 +93,9 @@ object breakOpt:
8393
test4(-1)
8494
assert(test5(2) == 1)
8595
assert(test6(3) == 18)
86-
assert(test7(3) == Some(4))
96+
assert(test7(3) == Some(14))
8797
assert(test7(-3) == None)
88-
89-
98+
assert(test8(3) == Some(4))
99+
assert(test8(-3) == None)
100+
assert(test9(3) == Some(4))
101+
assert(test9(-3) == None)

0 commit comments

Comments
 (0)