An unnamed break in a block now gives an UnnamedBreak warning (#20901)
* unnamed break in the block now gives an error * bootstrap * fixes * more fixes * break with label * label again * one moee * Delete test5.txt * it now gives a UnnamedBreak warning * change the URL of bump back to the original one
This commit is contained in:
parent
d149727f34
commit
ef29987781
16 changed files with 85 additions and 20 deletions
|
|
@ -19,7 +19,7 @@ block tbreak:
|
|||
run = false
|
||||
block myblock:
|
||||
if true:
|
||||
break
|
||||
break myblock
|
||||
echo "leaving myblock"
|
||||
x = true
|
||||
doAssert(x)
|
||||
|
|
@ -95,3 +95,22 @@ block tnestif:
|
|||
else:
|
||||
writeLine(stdout, "looks like Python")
|
||||
#OUT i == 2
|
||||
|
||||
# bug https://github.com/nim-lang/RFCs/issues/451
|
||||
for i in 1..2: # works
|
||||
break
|
||||
|
||||
block: # works
|
||||
for i in 1..2:
|
||||
break
|
||||
|
||||
block: # works
|
||||
block:
|
||||
discard 12 + 3
|
||||
for i in 1..2:
|
||||
break
|
||||
|
||||
block named: # works
|
||||
if true:
|
||||
break named
|
||||
doAssert false, "not reached"
|
||||
|
|
|
|||
15
tests/controlflow/tunamedbreak.nim
Normal file
15
tests/controlflow/tunamedbreak.nim
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
|
||||
discard """
|
||||
cmd: "nim check $file"
|
||||
action: "reject"
|
||||
nimout: '''
|
||||
tunamedbreak.nim(12, 5) Error: Using an unnamed break in a block is deprecated; Use a named block with a named break instead [UnnamedBreak]
|
||||
tunamedbreak.nim(15, 3) Error: Using an unnamed break in a block is deprecated; Use a named block with a named break instead [UnnamedBreak]
|
||||
'''
|
||||
"""
|
||||
for i in 1..2: # errors
|
||||
block:
|
||||
break
|
||||
|
||||
block: # errors
|
||||
break
|
||||
Loading…
Add table
Add a link
Reference in a new issue