Skip to content

Commit

Permalink
Disallow multiple types per case in switch
Browse files Browse the repository at this point in the history
  • Loading branch information
aardappel committed Oct 5, 2023
1 parent a9f537c commit b7522d2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions dev/src/lobster/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -1478,6 +1478,14 @@ struct Parser {
if (lex.token == T_IDENT) {
auto udt = st.LookupSpecialization(lex.sattr);
if (udt) {
if (pattern->Arity()) {
// We can lift this restriction in theory, by finding the common
// supertype for these multiple types in Case::TypeCheck, but
// then then exhaustiveness checking would get complicated if that
// doesn't cover all subtype cases.. so then the user would be better
// of using that supertype directly.
Error("can currently match only one type per case");
}
lex.Next();
f = new UDTRef(lex, udt);
}
Expand Down

0 comments on commit b7522d2

Please sign in to comment.