summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorArne Döring <arne.doering@gmx.net>2020-02-09 13:51:36 +0100
committerGitHub <noreply@github.com>2020-02-09 13:51:36 +0100
commit2fee89f7db54e1425ba43c3d9a5eb4156eb6c765 (patch)
tree4e23180d5081b5fab0bb38f67306fd0b9a1c9ed5
parent7939319379ba72beba8c15230b0a4229f7bcc1f1 (diff)
downloadNim-2fee89f7db54e1425ba43c3d9a5eb4156eb6c765.tar.gz
fix #13255 (#13275) [backport]
-rw-r--r--compiler/semstmts.nim4
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index 69022f4ad..7636705e0 100644
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -945,9 +945,9 @@ proc semCase(c: PContext, n: PNode; flags: TExprFlags): PNode =
       checkSonsLen(x, 1, c.config)
       x[0] = semExprBranchScope(c, x[0])
       typ = commonType(typ, x[0])
-      hasElse = true
-      if chckCovered and covered == toCover(c, n[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)