Skip to content

Commit 4a284d1

Browse files
committed
fix can not union table with other basic types
1 parent a7be41a commit 4a284d1

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# changelog
22

33
## 3.2.4
4-
* `FIX` hover: can not union `unknown` with other types
4+
* `FIX` hover: can not union `table` with other basic types
55

66
## 3.2.3
77
`2022-5-16`

script/vm/infer.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ local viewNodeSwitch = util.switch()
7676
: case 'global'
7777
: call(function (source, infer)
7878
if source.cate == 'type' then
79-
if source.name ~= 'unknown' then
79+
if not guide.isBasicType(source.name) then
8080
infer._hasClass = true
8181
end
8282
if source.name == 'number' then

test/type_inference/init.lua

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2308,3 +2308,18 @@ end
23082308
23092309
local <?z?> = f()
23102310
]]
2311+
2312+
TEST 'number|table' [[
2313+
local function returnI()
2314+
return a + 1
2315+
end
2316+
2317+
local function f()
2318+
if x then
2319+
return returnI()
2320+
end
2321+
return {}
2322+
end
2323+
2324+
local <?z?> = f()
2325+
]]

0 commit comments

Comments
 (0)