Skip to content

For comprehension bug when using type casting #21544

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

Closed
road21 opened this issue Sep 5, 2024 · 2 comments · Fixed by #21647
Closed

For comprehension bug when using type casting #21544

road21 opened this issue Sep 5, 2024 · 2 comments · Fixed by #21647

Comments

@road21
Copy link
Contributor

road21 commented Sep 5, 2024

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

@road21 road21 added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Sep 5, 2024
@Gedochao Gedochao added area:typer area:spec regression:scala2 and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Sep 5, 2024
@Gedochao
Copy link
Contributor

Gedochao commented Sep 5, 2024

@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
Copy link
Member

sjrd commented Sep 5, 2024

Looks like a bug to me. It should compile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants