From 8cfce70738de2d488b621e6936e6398bfbe0a3ce Mon Sep 17 00:00:00 2001 From: Bung Date: Wed, 23 Nov 2022 03:08:17 +0800 Subject: [PATCH] =?UTF-8?q?fix=20#18964=20Small=20string=20case=20with=20e?= =?UTF-8?q?lse=20statement=20first=20in=20AST=20evaluat=E2=80=A6=20(#20862?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix #18964 Small string case with else statement first in AST evaluates wrongly --- compiler/semstmts.nim | 7 ++++++- tests/casestmt/t18964.nim | 12 ++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 tests/casestmt/t18964.nim diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index ab8c23ba46..f2434db876 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -1116,7 +1116,10 @@ proc semCase(c: PContext, n: PNode; flags: TExprFlags; expectedType: PType = nil popCaseContext(c) closeScope(c) return handleCaseStmtMacro(c, n, flags) - + template invalidOrderOfBranches(n: PNode) = + localError(c.config, n.info, "invalid order of case branches") + break + for i in 1..