diff options
-rw-r--r-- | changelog.md | 1 | ||||
-rw-r--r-- | script/vm/compiler.lua | 2 | ||||
-rw-r--r-- | test/type_inference/init.lua | 11 |
3 files changed, 13 insertions, 1 deletions
diff --git a/changelog.md b/changelog.md index bd1cede4..af8beb93 100644 --- a/changelog.md +++ b/changelog.md @@ -13,6 +13,7 @@ ``` * `NEW` diagnostics: * `unknown-operator` +* `FIX` [#1292](https://github.com/sumneko/lua-language-server/issues/1292) * `FIX` [#1294](https://github.com/sumneko/lua-language-server/issues/1294) ## 3.4.2 diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua index 995fe395..374ada92 100644 --- a/script/vm/compiler.lua +++ b/script/vm/compiler.lua @@ -714,7 +714,7 @@ function vm.selectNode(list, index) else ---@type vm.node result = vm.compileNode(exp) - if exp.type == 'varargs' and result:isEmpty() then + if result:isEmpty() then result:merge(vm.declareGlobal('type', 'unknown')) end end diff --git a/test/type_inference/init.lua b/test/type_inference/init.lua index 2ae79a46..cc3b27e2 100644 --- a/test/type_inference/init.lua +++ b/test/type_inference/init.lua @@ -3629,3 +3629,14 @@ local <?b?> TEST 'integer|false' [[ local <?b?> = X == 1 and X == 1 and 1 ]] + +TEST 'unknown|nil' [[ +local function f() + if X then + return ({})[1] + end + return nil +end + +local <?n?> = f() +]] |