fix #18964 Small string case with else statement first in AST evaluat… (#20862)

fix #18964 Small string case with else statement first in AST evaluates wrongly
This commit is contained in:
Bung
2022-11-23 03:08:17 +08:00
committed by GitHub
parent 0448f30fd9
commit 8cfce70738
2 changed files with 18 additions and 1 deletions

12
tests/casestmt/t18964.nim Normal file
View File

@@ -0,0 +1,12 @@
discard """
errormsg: "invalid order of case branches"
"""
import macros
macro genCase(val: string): untyped =
result = nnkCaseStmt.newTree(val,
nnkElse.newTree(quote do: echo "else"),
nnkOfBranch.newTree(newLit("miauz"), quote do: echo "first branch"))
genCase("miauz")