parent
bb23d903b6
commit
722abbe9c9
2 changed files with 18 additions and 0 deletions
|
|
@ -404,6 +404,9 @@ proc genComputedGoto(p: BProc; n: PNode) =
|
||||||
localError(p.config, it.info,
|
localError(p.config, it.info,
|
||||||
"case statement must be exhaustive for computed goto"); return
|
"case statement must be exhaustive for computed goto"); return
|
||||||
casePos = i
|
casePos = i
|
||||||
|
if enumHasHoles(it.sons[0].typ):
|
||||||
|
localError(p.config, it.info,
|
||||||
|
"case statement cannot work on enums with holes for computed goto"); return
|
||||||
let aSize = lengthOrd(p.config, it.sons[0].typ)
|
let aSize = lengthOrd(p.config, it.sons[0].typ)
|
||||||
if aSize > 10_000:
|
if aSize > 10_000:
|
||||||
localError(p.config, it.info,
|
localError(p.config, it.info,
|
||||||
|
|
|
||||||
15
tests/casestmt/t7699.nim
Normal file
15
tests/casestmt/t7699.nim
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
discard """
|
||||||
|
line: 13
|
||||||
|
errormsg: "case statement cannot work on enums with holes for computed goto"
|
||||||
|
"""
|
||||||
|
|
||||||
|
type
|
||||||
|
X = enum
|
||||||
|
A = 0, B = 100
|
||||||
|
|
||||||
|
var z = A
|
||||||
|
while true:
|
||||||
|
{.computedGoto.}
|
||||||
|
case z
|
||||||
|
of A: discard
|
||||||
|
of B: discard
|
||||||
Loading…
Add table
Add a link
Reference in a new issue