bug icon indicating copy to clipboard operation
bug copied to clipboard

False "dead code" warning with throwing parameter default value

Open scabug opened this issue 10 years ago • 2 comments

With -Ywarn-dead-code :

Welcome to Scala version 2.11.6 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_45).
Type in expressions to have them evaluated.
Type :help for more information.

scala> def foo[T](v: => T = throw new Exception()): T = v
<console>:7: warning: dead code following this construct
       def foo[T](v: => T = throw new Exception()): T = v
                            ^

scabug avatar Apr 30 '15 20:04 scabug

Imported From: https://issues.scala-lang.org/browse/SI-9292?orig=1 Reporter: Espen Wiborg (espenhw) Affected Versions: 2.11.6

scabug avatar Apr 30 '15 20:04 scabug

Remains reproducible in Scala 2.13.16.

I don't think Scala 3 has this lint.

SethTisue avatar Mar 11 '25 19:03 SethTisue