summaryrefslogtreecommitdiff
path: root/test/diagnostics/global-in-nil-env.lua
blob: a0b8cd3e61ddbaa044556f70363a9ea3620a9d88 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
TEST [[
local _
print(_)
local _
print(_)
local _ENV
<!print!>(_ENV) -- 由于重定义了_ENV,因此print变为了未定义全局变量
]]

TEST [[
_ENV = nil
<!print!>(<!A!>) -- `print` and `A` should warning 
]]

TEST [[
local _ENV = nil
<!print!>(<!A!>) -- `print` and `A` should warning 
]]

TEST [[
_ENV = {}
print(A) -- no warning
]]

TEST [[
local _ENV = {}
print(A) -- no warning
]]

TEST [[
_ENV = nil
<!GLOBAL!> = 1 --> _ENV.GLOBAL = 1
]]

TEST [[
_ENV = nil
local _ = <!print!> --> local _ = _ENV.print
]]

TEST [[
local function foo(_ENV)
    Joe = "human"
end
]]