summaryrefslogtreecommitdiff
path: root/script/vm
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2023-02-02 15:07:35 +0800
committer最萌小汐 <sumneko@hotmail.com>2023-02-02 15:07:35 +0800
commit034d4f4793e0934a697e8cf2c6219e8c5648472d (patch)
tree606155ab4953cd38e06d8cb87783723e9035ea2e /script/vm
parenteeb9ba02ab7b4d51dced712c49eaf976be46bc74 (diff)
downloadlua-language-server-034d4f4793e0934a697e8cf2c6219e8c5648472d.zip
special treate for return values of require
2nd should be unknown since Lua 5.3, otherwise should be nil #1868
Diffstat (limited to 'script/vm')
-rw-r--r--script/vm/compiler.lua15
1 files changed, 15 insertions, 0 deletions
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua
index 3bebbc20..4f97b0e0 100644
--- a/script/vm/compiler.lua
+++ b/script/vm/compiler.lua
@@ -1484,6 +1484,21 @@ local compilerSwitch = util.switch()
return
end
if func.special == 'require' then
+ if index == 2 then
+ local uri = guide.getUri(source)
+ local version = config.get(uri, 'Lua.runtime.version')
+ if version == 'Lua 5.3'
+ or version == 'Lua 5.4' then
+ vm.setNode(source, vm.declareGlobal('type', 'unknown'))
+ else
+ vm.setNode(source, vm.declareGlobal('type', 'nil'))
+ end
+ return
+ end
+ if index >= 3 then
+ vm.setNode(source, vm.declareGlobal('type', 'nil'))
+ return
+ end
if not args then
return
end