Closed
Description
Compiler version
3.0.0
Minimized code
Minimal repros:
- https://github.com/Matechs-Garage/scala-3-zio/blob/scala-bug-union/src/main/scala/Main.scala
- https://github.com/Matechs-Garage/scala-3-zio/blob/scala-bug-has/src/main/scala/Main.scala
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 |)