-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Inconsistent Behaviour in Union and Intersection Types with compiler crashes #12896
Labels
Comments
Is 2. the same issue as #12077 ? |
Minimized 1. (which I'll take this issue to be about, if there are other issues they need to be opened separately): trait IO[E] {
def map[B](f: Any => B): IO[E] = ???
def flatMap[C](f: Any => IO[C]): IO[E | C] = ???
}
class Test {
def test: Unit = {
val a: IO[Nothing] = ???
val d = a.flatMap(y => a.flatMap(z => a.map(_ => z)))
}
} |
This is likely an instance of #8900 |
It seem related I can't say if it is 100% the same but it appears so |
odersky
added a commit
to dotty-staging/dotty
that referenced
this issue
Apr 7, 2022
Closes scala#9287 Closes scala#12640 Closes scala#12896
Merged
michelou
pushed a commit
to michelou/dotty
that referenced
this issue
Apr 25, 2022
Closes scala#9287 Closes scala#12640 Closes scala#12896
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Compiler version
3.0.0
Minimized code
Minimal repros:
Output
crashes with https://github.com/Matechs-Garage/scala-3-zio/blob/scala-bug-union/error.log, some unions have duplicates as per comments in code.
main
type is inferred asIO[Nothing, Nothing, Unit]
meaning the compiler has inferredX
to beNothing
inHas[Math] & X => Has[Math] & Has[Console]
Expectation
shouldn't crash and union types should not show duplicates
removing
Has
from the code like in https://github.com/Matechs-Garage/scala-3-zio/blob/scala-ok-intersection/src/main/scala/Main.scala correctly inferX
toConsole
inMath & X => Math & Console
The
master
branch contains a "kind of working" variant of the expected behavior worked around by playing with the parameter variance (even though it shouldn't be needed given & and |)The text was updated successfully, but these errors were encountered: