summaryrefslogtreecommitdiff
path: root/test/diagnostics/global-in-nil-env.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/diagnostics/global-in-nil-env.lua')
-rw-r--r--test/diagnostics/global-in-nil-env.lua44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/diagnostics/global-in-nil-env.lua b/test/diagnostics/global-in-nil-env.lua
new file mode 100644
index 00000000..a0b8cd3e
--- /dev/null
+++ b/test/diagnostics/global-in-nil-env.lua
@@ -0,0 +1,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
+]]