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
{{ message }}
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.
The JVM backend always emits this default case if a switch does not have an explicit else case:
elsethrownew .com.redhat.ceylon.compiler.java.language.EnumeratedTypeError("Supposedly exhaustive switch was not exhaustive");
I think it would be a good idea to do this on the JS backend as well. After all, the JS platform makes even less guarantees at runtime than the JVM (e. g. no guarantee that a String member actually contains a String value), and so a switch might not be exhaustive not only due to compiler bugs (e. g. #6311), but also simply because other parts of the program might not adhere to Ceylon’s typing rules (for example, TypeScript enums are just glorified integers, and there’s nothing to prevent someone from assigning 1337 to an enum with only the cases 0 and 1).
The text was updated successfully, but these errors were encountered:
String|Integerfoo() => "It's a string";
sharedvoidrun() {
switch(x=foo())
case (isInteger) {
print("It's an int");
}
case (isString) {
print("It's a string");
}
print("realmente fue ``className(foo())``");
}
And then override foo with a native file ``function foo() { return 3.14; }` then the switch won't cover that case and it's going to be hell to debug. So I guess this might be necessary after all.
The JVM backend always emits this default case if a
switch
does not have an explicitelse
case:I think it would be a good idea to do this on the JS backend as well. After all, the JS platform makes even less guarantees at runtime than the JVM (e. g. no guarantee that a
String
member actually contains aString
value), and so a switch might not be exhaustive not only due to compiler bugs (e. g. #6311), but also simply because other parts of the program might not adhere to Ceylon’s typing rules (for example, TypeScript enums are just glorified integers, and there’s nothing to prevent someone from assigning1337
to an enum with only the cases0
and1
).The text was updated successfully, but these errors were encountered: