Skip to content

Commit 8215d01

Browse files
author
Lucy Martin
committed
scala#20145 - bugfix when a return tail recurse is called inside a val definition, previously this would neither optimise nor fail.
1 parent c50d0a3 commit 8215d01

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

compiler/src/dotty/tools/dotc/transform/TailRec.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,10 @@ class TailRec extends MiniPhase {
431431

432432
case tree: ValDef =>
433433
// This could contain a return statement in a code block, so we do have to go into it.
434-
noTailTransform(tree)
434+
cpy.ValDef(tree)(
435+
tree.name,
436+
noTailTransform(tree.rhs)
437+
)
435438

436439
case tree: DefDef =>
437440
if (isMandatory)

0 commit comments

Comments
 (0)