diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2025-05-18 11:43:43 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2025-05-18 11:43:43 -0300 |
| commit | abbae57c7844b1121e7251d56f681394f20c1821 (patch) | |
| tree | 823201f4d2631fcae027117681553de80b2c96f0 /testes/goto.lua | |
| parent | f2c1531e6cacb10926158d8def5fa5841a0f357e (diff) | |
| download | lua-abbae57c7844b1121e7251d56f681394f20c1821.tar.gz lua-abbae57c7844b1121e7251d56f681394f20c1821.tar.bz2 lua-abbae57c7844b1121e7251d56f681394f20c1821.zip | |
Variable attributes can prefix name list
In this format, the attribute applies to all names in the list;
e.g. "global<const> print, require, math".
Diffstat (limited to 'testes/goto.lua')
| -rw-r--r-- | testes/goto.lua | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/testes/goto.lua b/testes/goto.lua index 3f1f6e69..44486e20 100644 --- a/testes/goto.lua +++ b/testes/goto.lua | |||
| @@ -1,9 +1,9 @@ | |||
| 1 | -- $Id: testes/goto.lua $ | 1 | -- $Id: testes/goto.lua $ |
| 2 | -- See Copyright Notice in file lua.h | 2 | -- See Copyright Notice in file lua.h |
| 3 | 3 | ||
| 4 | global require | 4 | global<const> require |
| 5 | global print, load, assert, string, setmetatable | 5 | global<const> print, load, assert, string, setmetatable |
| 6 | global collectgarbage, error | 6 | global<const> collectgarbage, error |
| 7 | 7 | ||
| 8 | print("testing goto and global declarations") | 8 | print("testing goto and global declarations") |
| 9 | 9 | ||
| @@ -304,7 +304,7 @@ do | |||
| 304 | 304 | ||
| 305 | -- global variables cannot be to-be-closed | 305 | -- global variables cannot be to-be-closed |
| 306 | checkerr("global X<close>", "cannot be") | 306 | checkerr("global X<close>", "cannot be") |
| 307 | checkerr("global * <close>", "cannot be") | 307 | checkerr("global <close> *", "cannot be") |
| 308 | 308 | ||
| 309 | do | 309 | do |
| 310 | local X = 10 | 310 | local X = 10 |
| @@ -345,7 +345,7 @@ do | |||
| 345 | end | 345 | end |
| 346 | 346 | ||
| 347 | checkerr([[ | 347 | checkerr([[ |
| 348 | global foo <const>; | 348 | global<const> foo; |
| 349 | function foo (x) return end -- ERROR: foo is read-only | 349 | function foo (x) return end -- ERROR: foo is read-only |
| 350 | ]], "assign to const variable 'foo'") | 350 | ]], "assign to const variable 'foo'") |
| 351 | 351 | ||
| @@ -357,7 +357,7 @@ do | |||
| 357 | ]], "%:2%:") -- correct line in error message | 357 | ]], "%:2%:") -- correct line in error message |
| 358 | 358 | ||
| 359 | checkerr([[ | 359 | checkerr([[ |
| 360 | global * <const>; | 360 | global<const> *; |
| 361 | print(X) -- Ok to use | 361 | print(X) -- Ok to use |
| 362 | Y = 1 -- ERROR | 362 | Y = 1 -- ERROR |
| 363 | ]], "assign to const variable 'Y'") | 363 | ]], "assign to const variable 'Y'") |
