Skip to content

Commit 01a09c6

Browse files
committed
some fix
1 parent d1fd05e commit 01a09c6

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

script/config/template.lua

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ local diag = require 'proto.diagnostic'
55
---@class config.unit
66
---@field caller function
77
---@field _checker fun(self: config.unit, value: any): boolean
8+
---@field name string
9+
---@field [string] config.unit
10+
---@operator shl: config.unit
11+
---@operator shr: config.unit
12+
---@operator call: config.unit
813
local mt = {}
914
mt.__index = mt
1015

@@ -52,11 +57,7 @@ local function register(name, default, checker, loader, caller)
5257
}
5358
end
5459

55-
---@class config.template
56-
---@field [string] config.template
57-
---@operator shl: config.template
58-
---@operator shr: config.template
59-
---@operator call: config.template
60+
---@type config.unit
6061
local Type = setmetatable({}, { __index = function (_, name)
6162
local unit = {}
6263
for k, v in pairs(units[name]) do

script/vm/compiler.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,7 @@ function vm.getClassFields(suri, object, key, ref, pushResult)
295295
hasFounded[fieldKey] = true
296296
end
297297
end
298-
end
299-
if not hasFounded[fieldKey] then
298+
elseif key and not hasFounded[key] then
300299
local keyType = type(key)
301300
if keyType == 'table' then
302301
-- ---@field [integer] boolean -> class[integer]

test/type_inference/init.lua

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3576,3 +3576,21 @@ local t = {
35763576
<?x?> = a(),
35773577
}
35783578
]]
3579+
3580+
TEST 'boolean' [[
3581+
---@class A
3582+
---@field n number
3583+
---@field [string] boolean
3584+
local t
3585+
3586+
local <?x?> = t.xx
3587+
]]
3588+
3589+
TEST 'number' [[
3590+
---@class A
3591+
---@field n number
3592+
---@field [string] boolean
3593+
local t
3594+
3595+
local <?x?> = t.n
3596+
]]

0 commit comments

Comments
 (0)