-
Notifications
You must be signed in to change notification settings - Fork 1.1k
AssertionError: invalid prefix MethodType ... #16842
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
Comments
Hi! Thank you for submitting the issue. Fortunately, this appears to be fixed on main (21729d2) and in 3.3.0-RC2, which means that this will be fixed in the next version of Scala (3.3.0). Instead of a crash we now get errors, all of which appear to be correct: -- [E007] Type Mismatch Error: main.scala:24:8 ---------------------------------
24 | Liter(SemanticArray[SemanticInt.type], x)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| Found: Int => SemanticArray[SemanticInt.type]
| Required: SemanticArray[SemanticType]
|
| longer explanation available when compiling with `-explain`
-- [E007] Type Mismatch Error: main.scala:24:41 --------------------------------
24 | Liter(SemanticArray[SemanticInt.type], x)
| ^
|Found: (x : List[Expr2[SemanticInt.type]])
|Required: ?1.T
|
|where: ?1 is an unknown value of type (dim: Int): SemanticArray[SemanticInt.type]
|
| longer explanation available when compiling with `-explain` As an extra, here is a version that fixes the above errors (and also compiles on 3.2.2): sealed trait Expr1
sealed trait Literal extends Expr1
case class ArrayLiter(elems: List[Expr1]) extends Literal
sealed trait SemanticType {
type T // the type with which a literal of this semanticType is represented
}
case object SemanticInt extends SemanticType {
type T = Int
}
case class SemanticArray[U <: SemanticType](dim: Int) extends SemanticType {
type T = List[U]
}
sealed trait Expr2[+T]
class Liter[T <: SemanticType](val ty: T, val value: ty.T) extends Expr2[T]
def typecheckArrayLiter(
a: ArrayLiter
): Liter[SemanticArray[? <: SemanticType]] = { // bit of a hack here, usually we would just make SemanticArray type parameter covariant, but here we would get an error: "covariant type U occurs in invariant position in type = List[U] of type T"
val x: List[SemanticInt.type] = List() // removed Expr2 from type declaration
Liter(SemanticArray[SemanticInt.type](0), x) // added a missing argument
}
|
I would expect "cannot reproduce" to mean the reported symptom can't be reproduced in a lab setting, rather than "can't be reproduced because the bug is already fixed." (I happened to arrive here because "cannot reproduce" is also a challenge.) |
@som-snytt you are right "cannot reproduce" should be used when we can't be reproduced in a lab setting.
It does fail as reported in 3.2.2. |
Compiler version
3.2.2
Minimized code
Output (click arrow to expand)
The text was updated successfully, but these errors were encountered: