Skip to content

Commit 83f2b38

Browse files
committed
fix can not union unknown with other types
1 parent 25a7853 commit 83f2b38

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# changelog
22

3+
## 3.2.4
4+
* `FIX` hover: can not union `unknown` with other types
5+
36
## 3.2.3
47
`2022-5-16`
58
* `CHG` parse `.luarc.json` as jsonc. In order to please the editor, it also supports `.luarc.jsonc` as the file name.

script/vm/infer.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ local viewNodeSwitch = util.switch()
7676
: case 'global'
7777
: call(function (source, infer)
7878
if source.cate == 'type' then
79-
infer._hasClass = true
79+
if source.name ~= 'unknown' then
80+
infer._hasClass = true
81+
end
8082
if source.name == 'number' then
8183
infer._hasNumber = true
8284
end

test/type_inference/init.lua

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2297,3 +2297,14 @@ end
22972297
22982298
print(<?t?>)
22992299
]]
2300+
2301+
TEST 'table|unknown' [[
2302+
local function f()
2303+
if x then
2304+
return y
2305+
end
2306+
return {}
2307+
end
2308+
2309+
local <?z?> = f()
2310+
]]

0 commit comments

Comments
 (0)