diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2025-05-13 11:43:10 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2025-05-13 11:43:10 -0300 |
| commit | 3b9dd52be02fd43c598f4adb6fa7844e6a573923 (patch) | |
| tree | 8f858942f5db0e3d9d7cad503b59ee1541a60aa6 /testes/locals.lua | |
| parent | 7dc6aae29057c9dc4588f780c7abd72a62ff4c8e (diff) | |
| download | lua-3b9dd52be02fd43c598f4adb6fa7844e6a573923.tar.gz lua-3b9dd52be02fd43c598f4adb6fa7844e6a573923.tar.bz2 lua-3b9dd52be02fd43c598f4adb6fa7844e6a573923.zip | |
Collective declaration for globals ('global *')
Diffstat (limited to 'testes/locals.lua')
| -rw-r--r-- | testes/locals.lua | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/testes/locals.lua b/testes/locals.lua index 421595bb..99ff9edc 100644 --- a/testes/locals.lua +++ b/testes/locals.lua | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | -- $Id: testes/locals.lua $ | 1 | -- $Id: testes/locals.lua $ |
| 2 | -- See Copyright Notice in file lua.h | 2 | -- See Copyright Notice in file lua.h |
| 3 | 3 | ||
| 4 | global * <const> | ||
| 5 | |||
| 4 | print('testing local variables and environments') | 6 | print('testing local variables and environments') |
| 5 | 7 | ||
| 6 | local debug = require"debug" | 8 | local debug = require"debug" |
| @@ -39,9 +41,11 @@ f = nil | |||
| 39 | local f | 41 | local f |
| 40 | local x = 1 | 42 | local x = 1 |
| 41 | 43 | ||
| 42 | a = nil | 44 | do |
| 43 | load('local a = {}')() | 45 | global a; a = nil |
| 44 | assert(a == nil) | 46 | load('local a = {}')() |
| 47 | assert(a == nil) | ||
| 48 | end | ||
| 45 | 49 | ||
| 46 | function f (a) | 50 | function f (a) |
| 47 | local _1, _2, _3, _4, _5 | 51 | local _1, _2, _3, _4, _5 |
| @@ -154,7 +158,7 @@ local _ENV = (function (...) return ... end)(_G, dummy) -- { | |||
| 154 | do local _ENV = {assert=assert}; assert(true) end | 158 | do local _ENV = {assert=assert}; assert(true) end |
| 155 | local mt = {_G = _G} | 159 | local mt = {_G = _G} |
| 156 | local foo,x | 160 | local foo,x |
| 157 | A = false -- "declare" A | 161 | global A; A = false -- "declare" A |
| 158 | do local _ENV = mt | 162 | do local _ENV = mt |
| 159 | function foo (x) | 163 | function foo (x) |
| 160 | A = x | 164 | A = x |
