-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Inlined mapping function fails when an inlined match is used #14325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This doesn't even work on a single element; see #13774 def toCSV: [t] => t => String = [t] => (x: t) => x match
case x: String => s"\"$x\""
case x:_ => x.toString
inline def toCSVinlined: [t] => t => String = [t] => (x: t) => inline x match
case x: String => s"\"$x\""
case x:_ => x.toString
@main def m =
println(toCSV("foo"))
println(toCSVinlined("foo")) |
@Adam-Vandervorst You are correct. Should have checked that before reporting. I will edit the title accordingly. Thank you. However, assuming no tuples are used, this case is not quite the same as the one you referenced. In that case we had an TIA |
def toCSV: [t] => t => String = [t] => (x: t) => x match
case x: String => s"\"$x\""
case x => "other"
inline def toCSVinlined: [t] => t => String = [t] => (x: t) => inline x match
case x: String => s"\"$x\""
case x => "other"
inline def toCSVinlined2[T](x: T): String = inline x match
case x: String => s"\"$x\""
case x => "other"
@main def test =
println(toCSV("foo")) // "foo"
println(toCSVinlined("foo")) // other
println(toCSVinlined2("foo")) // "foo" the inline match of |
I confess I am confused. Aren't TIA |
Uh oh!
There was an error while loading. Please reload this page.
Compiler version
3.1.0
Minimized code
works and prints
But this does not (inline match):
Output
In the case above I get:
It seems like no type information is available for use. The default case is used.
Expectation
I was expecting to have the same output. If this is to be expected then I have seen several open issues regarding matching tuples inline, but cannot say if this is the same issue.
Note: I tried to create scastie example but failed due to a compilation error on the latest and RC versions.
The text was updated successfully, but these errors were encountered: