fix #13255 (#13275) [backport]

(cherry picked from commit 2fee89f7db)
This commit is contained in:
Arne Döring
2020-02-09 13:51:36 +01:00
committed by narimiran
parent 3bf9ef537f
commit 8cdba8ea29

View File

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