scala / scala3

The Scala 3 compiler, also known as Dotty.
https://dotty.epfl.ch
Apache License 2.0
5.87k stars 1.06k forks source link

For comprehension bug when using type casting #21544

Closed road21 closed 8 hours ago

road21 commented 1 month ago

Compiler version

3.5.0, 3.3.3

Minimized code

https://scastie.scala-lang.org/road21/GozkhzC7QXaGpkbM7mNYUg/3

for {
  (x: Any) <- (List[Boolean]())
} yield x

Output

Compile error:

[error] cannot test if value of type Boolean is a reference of class Object
[error]   (x: Any) <- (List[Boolean]())
[error]    ^^^^^^

Expectation

No compiler error

Same code works fine in Scala 2.13

Gedochao commented 1 month ago

@sjrd should this actually compile, or is this not supported for a reason? (in which case it'd just need a better error message)

sjrd commented 1 month ago

Looks like a bug to me. It should compile.