-
Notifications
You must be signed in to change notification settings - Fork 21
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
"NoSuchElementException: head of empty list" caused by asInstanceOf with higher kinds #10700
Comments
Just for fun, eliminating the import scala.language.higherKinds
class Foo[X]
class Bar[X]
class CrashIt[A[_] >: Null] {
def cast(a: Any): A[Int] = null
}
val c = if (true) new CrashIt[Foo] else new CrashIt[Bar]
val x = c.cast("") |
Even shorter: without
(That's not purely code-golfing, this has fewer syntactic elements, and it has the advantage of a somewhat shorter stack trace of the error.) |
Ugh, just this line kills the REPL: class CrashIt[A[_]]
if (true) new CrashIt[Option] else new CrashIt[List] |
Yes, but it "works" outside of the REPL though... |
This goes way farther back (before 2.11, even). |
Uh-oh, note the ill-kinded type inference: scala> List(new CrashIt[Option], new CrashIt[List])
<console>:39: error: type mismatch;
found : CrashIt[Option]
required: CrashIt[_ >: List with Option <: Product with Serializable]
List(new CrashIt[Option], new CrashIt[List])
^
<console>:39: error: type mismatch;
found : CrashIt[List]
required: CrashIt[_ >: List with Option <: Product with Serializable]
List(new CrashIt[Option], new CrashIt[List])
^ Also, I don't understand why:
|
When computing the `lub/glb` of HKTs take care to produce well-kinded types. Improves type inference. A few tests with `-Xstrict-inference` were changed. Other tests reveal a limitation of higher-kinded existentials. Fixes scala/bug#8882 and promotes scala/bug#10700 to an error.
When computing the `lub/glb` of HKTs take care to produce well-kinded types. Improves type inference. A few tests with `-Xstrict-inference` were changed. Other tests reveal a limitation of higher-kinded existentials. Fixes scala/bug#8882 and promotes scala/bug#10700 to an error.
When computing the `lub/glb` of HKTs take care to produce well-kinded types. Improves type inference. A few tests with `-Xstrict-inference` were changed. Other tests reveal a limitation of higher-kinded existentials. Fixes scala/bug#8882 and promotes scala/bug#10700 to an error.
When computing the `lub/glb` of HKTs take care to produce well-kinded types. Improves type inference. A few tests with `-Xstrict-inference` were changed. Other tests reveal a limitation of higher-kinded existentials. Fixes scala/bug#8882 and promotes scala/bug#10700 to an error.
When computing the `lub/glb` of HKTs take care to produce well-kinded types. Improves type inference. A few tests with `-Xstrict-inference` were changed. Other tests reveal a limitation of higher-kinded existentials. Fixes scala/bug#8882 and promotes scala/bug#10700 to an error.
When computing the `lub/glb` of HKTs take care to produce well-kinded types. Improves type inference. A few tests with `-Xstrict-inference` were changed. Other tests reveal a limitation of higher-kinded existentials. Fixes scala/bug#8882 and promotes scala/bug#10700 to an error.
When computing the `lub/glb` of HKTs take care to produce well-kinded types when merging type constructor arguments that are supplied for a type constructor parameter. This improves type inference. A few tests with `-Xstrict-inference` were changed. Other tests reveal a limitation of higher-kinded existentials. Fixes scala/bug#8882 and promotes scala/bug#10700 to an error.
When computing the `lub/glb` of HKTs take care to produce well-kinded types when merging type constructor arguments that are supplied for a type constructor parameter. This improves type inference. A few tests with `-Xstrict-inference` were changed. Other tests reveal a limitation of higher-kinded existentials. Fixes scala/bug#8882 and promotes scala/bug#10700 to an error.
When computing the `lub/glb` of HKTs take care to produce well-kinded types when merging type constructor arguments that are supplied for a type constructor parameter. This improves type inference. A few tests with `-Xstrict-inference` were changed. Other tests reveal a limitation of higher-kinded existentials. Fixes scala/bug#8882 and promotes scala/bug#10700 to an error.
scala/scala#6352 promotes this to an error for 2.13 |
My PR is just not to crash when constructing a string. |
scala 2.12.4 typechecker crashes when trying to run the following script with "scala script.scala":
Stack trace:
Information about the used compiler and environment:
Some observations:
c.cast("")
is removedThe text was updated successfully, but these errors were encountered: