-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Labels
area:inlinebetter-errorsIssues concerned with improving confusing/unhelpful diagnostic messagesIssues concerned with improving confusing/unhelpful diagnostic messagesitype:enhancement
Description
Bug found by @asunluer.
Compiler version
3.0
3.7.4
3.8.0-RC1-bin-20250822-658c8bd-NIGHTLY
Minimized code
inline def f(): Long =
1L
inline def g(): Long =
inline val x = f()
x
inline def h(): Long =
inline if g() > 0L then 1L else 0L
@main def main(): Unit =
println(h())Output
$ scala -S 3.7.4 inline_val_bug.scala
Compiling project (Scala 3.7.4, JVM (23))
[error] ./inline_val_bug.scala:12:11
[error] Cannot reduce `inline if` because its condition is not a constant value: {
[error] inline val x: Long = 1L:Long
[error] x:Long
[error] }:Long > 0L
[error] println(h())
[error] ^^^
Error compiling project (Scala 3.7.4, JVM (23))
Compilation failedExpectation
Compiles, and constant-fold h() to 1L.
Metadata
Metadata
Assignees
Labels
area:inlinebetter-errorsIssues concerned with improving confusing/unhelpful diagnostic messagesIssues concerned with improving confusing/unhelpful diagnostic messagesitype:enhancement