Make unreachable else in case statements a warning instead of an error (#14190)

* Fix #14019 by making trailing else a warning

* Rename to UnreachableElse
This commit is contained in:
Clyybber 2020-05-02 16:09:02 +02:00 • committed by GitHub
commit 83547ec769
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 4 deletions

View file

@ -998,7 +998,7 @@ proc semCase(c: PContext, n: PNode; flags: TExprFlags): PNode =
x[0] = semExprBranchScope(c, x[0])
typ = commonType(typ, x[0])
if (chckCovered and covered == toCover(c, n[0].typ)) or hasElse:
localError(c.config, x.info, "invalid else, all cases are already covered")
message(c.config, x.info, warnUnreachableElse)
hasElse = true
chckCovered = false
else: