You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a typo in the docs, it should be .head and not .next() (the next method is not defined on scala.collection.Iterable).
However I don't think the code you wrote in the issue should compile, the match expression has one less case than the match type, so it doesn't fulfill the 3rd requirement stated in the Dependent Typing section (the match expression and the match type have the same number of cases).
@OlivierBlanvillain it would be really helpful if the compiler could give the reason why the match could not be type-checked successfully, in the original code. Instead, it currently yields many errors that point the programmer in the wrong direction. I did not know there was special reasoning in the compiler for making matches in types and terms match, so I thought the problem was with GADT-style reasoning and the like (as the errors seemed to imply).
Hello 👋 I copied Match types example from the docs into Scastie, but it didn't compile.
Compiler version
3.0.0-M3
Minimized code
Output
Found: Char
Required: LeafElem[X]
where: X is a type in method leafElem with bounds >: (?1 : String)
Found: t
Required: X
where: X is a type in method leafElem with bounds >: (?2 : Array[t])
Found: (x : X & AnyVal)
Required: LeafElem[X]
where: X is a type in method leafElem with bounds >: (?3 : AnyVal)
Expectation
Code should compile
The text was updated successfully, but these errors were encountered: