diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-10-29 14:26:48 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-10-29 14:26:48 -0300 |
commit | a006514ea138a29b6031058d9002b48a572b5dd6 (patch) | |
tree | b289a8af0c0497f2555784a0cf666659ceab0236 /testes/goto.lua | |
parent | 6e9b719694bffb8de711f182d405ec37d32ae0b1 (diff) | |
download | lua-a006514ea138a29b6031058d9002b48a572b5dd6.tar.gz lua-a006514ea138a29b6031058d9002b48a572b5dd6.tar.bz2 lua-a006514ea138a29b6031058d9002b48a572b5dd6.zip |
Big revamp in the implmentation of labels/gotos
Added restriction that, when a label is created, there cannot be
another label with the same name visible. That allows backward goto's
to be resolved when they are read. Backward goto's get a close if
they jump out of the scope of some variable; labels get a close only
if previous goto to it jumps out of the scope of some upvalue.
Diffstat (limited to 'testes/goto.lua')
-rw-r--r-- | testes/goto.lua | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/testes/goto.lua b/testes/goto.lua index 238bc04a..85038d02 100644 --- a/testes/goto.lua +++ b/testes/goto.lua | |||
@@ -14,6 +14,7 @@ errmsg([[ do ::l1:: end goto l1; ]], "label 'l1'") | |||
14 | 14 | ||
15 | -- repeated label | 15 | -- repeated label |
16 | errmsg([[ ::l1:: ::l1:: ]], "label 'l1'") | 16 | errmsg([[ ::l1:: ::l1:: ]], "label 'l1'") |
17 | errmsg([[ ::l1:: do ::l1:: end]], "label 'l1'") | ||
17 | 18 | ||
18 | 19 | ||
19 | -- undefined label | 20 | -- undefined label |
@@ -67,8 +68,6 @@ do | |||
67 | assert(assert(load(prog))() == 31) | 68 | assert(assert(load(prog))() == 31) |
68 | end | 69 | end |
69 | 70 | ||
70 | -- goto to correct label when nested | ||
71 | do goto l3; ::l3:: end -- does not loop jumping to previous label 'l3' | ||
72 | 71 | ||
73 | -- ok to jump over local dec. to end of block | 72 | -- ok to jump over local dec. to end of block |
74 | do | 73 | do |