diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-07-11 20:34:44 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-07-11 20:34:44 +0800 |
commit | 2469dbae153066fad83edcced82f17aee77d0a9f (patch) | |
tree | 1f2fc76ce1344ee9e48935f94fe5b44182325453 /test | |
parent | 8f056d36ec61dd91cfab282780dc1786df646fcb (diff) | |
download | lua-language-server-2469dbae153066fad83edcced82f17aee77d0a9f.zip |
resolve #1029
treat _ENV = {} as local _ENV = {}
local _ENV = nil will disable all globals
local _ENV = {} will enable all globals
local _ENV = {} ---@type mathlib will open globals in mathlib
Diffstat (limited to 'test')
-rw-r--r-- | test/diagnostics/common.lua | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test/diagnostics/common.lua b/test/diagnostics/common.lua index 0df678d1..fab02caf 100644 --- a/test/diagnostics/common.lua +++ b/test/diagnostics/common.lua @@ -133,6 +133,40 @@ _ENV = nil ]] TEST [[ +---@diagnostic disable: undefined-global +_ENV = nil +<!print!>(<!A!>) -- `print` and `A` should warning +]] + +TEST [[ +---@diagnostic disable: undefined-global +local _ENV = nil +<!print!>(<!A!>) -- `print` and `A` should warning +]] + +TEST [[ +_ENV = {} +print(A) -- no warning +]] + +TEST [[ +local _ENV = {} +print(A) -- no warning +]] + +TEST [[ +---@type iolib +_ENV = {} +<!print!>(stderr) -- `print` is warning but `stderr` is not +]] + +TEST [[ +---@type iolib +local _ENV = {} +<!print!>(stderr) -- `print` is warning but `stderr` is not +]] + +TEST [[ local _ENV = { print = print } print(1) ]] |