You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
object Inline1:
inline def foo( i:Int): Int =
inline if i == 0 then -1
else Math.abs(i)
def bar(i:Int): Int = foo(i) // as expected, fails to compile
// ^^^^^^
// Cannot reduce `inline if` because its condition is not a constant value: i.==(0)
object Inline2:
inline def foo( i:Int): Int =
inline i match
case 0 => -1
case x:Int => Math.abs(x)
def bar(i:Int): Int = foo(i) // a compilation error was expected, but none is reported
Expectation
inline is a command in Scala 3.0.0, not an implementation hint:
=> def bar() should fail in conjunction with inline match, as it does with inline if.
The text was updated successfully, but these errors were encountered:
I think the current behavior is comprehensible, as follows. At compile time, case 0 isn't known to match, so the compiler proceeds to the next case, which does match. It may help to understand that here case 0 is a type test, not a runtime equality test. If it's the other semantics you wanted, inline if is available.
related: #13774 — there is some discussion there. It's probably better to discuss further on 13774 unless someone wants to make a case that this ticket is definitely different.
Uh oh!
There was an error while loading. Please reload this page.
Minimized code
3.0.0-M3
Expectation
inline is a command in Scala 3.0.0, not an implementation hint:
=>
def bar()
should fail in conjunction withinline match
, as it does withinline if
.The text was updated successfully, but these errors were encountered: