diff options
-rw-r--r-- | script/core/hover/table.lua | 6 | ||||
-rw-r--r-- | script/vm/compiler.lua | 8 | ||||
-rw-r--r-- | test/hover/init.lua | 20 |
3 files changed, 12 insertions, 22 deletions
diff --git a/script/core/hover/table.lua b/script/core/hover/table.lua index a21910e3..88808daa 100644 --- a/script/core/hover/table.lua +++ b/script/core/hover/table.lua @@ -113,8 +113,8 @@ end local function getOptMap(fields, keyMap) local optMap = {} for _, field in ipairs(fields) do - if field.type == 'doc.field.name' then - if field.parent.optional then + if field.type == 'doc.field' then + if field.optional then local key = vm.getKeyName(field) if keyMap[key] then optMap[key] = true @@ -145,7 +145,7 @@ local function getInferMap(fields, keyMap) await.delay() local ifr = infer.getInfer(field) if inferMap[key] then - inferMap[key]:merge(ifr) + inferMap[key] = inferMap[key]:merge(ifr) else inferMap[key] = ifr end diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua index 4dc3edef..fd1d1d5d 100644 --- a/script/vm/compiler.lua +++ b/script/vm/compiler.lua @@ -111,14 +111,14 @@ local searchFieldSwitch = util.switch() or (fn.name == 'number' and type(key) == 'number') or (fn.name == 'integer' and math.tointeger(key)) or (fn.name == 'string' and type(key) == 'string') then - pushResult(field.extends) + pushResult(field) end end end end if fieldKey.type == 'doc.field.name' then if key == nil or fieldKey[1] == key then - pushResult(field.extends) + pushResult(field) end end end @@ -852,6 +852,10 @@ local compilerSwitch = util.switch() : call(function (source) nodeMgr.setNode(source, m.compileNode(source.extends)) end) + : case 'doc.type.field' + : call(function (source) + nodeMgr.setNode(source, m.compileNode(source.extends)) + end) : case 'doc.param' : call(function (source) nodeMgr.setNode(source, m.compileNode(source.extends)) diff --git a/test/hover/init.lua b/test/hover/init.lua index 1fced5b3..6570c38c 100644 --- a/test/hover/init.lua +++ b/test/hover/init.lua @@ -1676,7 +1676,7 @@ TEST [[ ]] [[ global a: { - b: integer, + b: integer = 600, } ]] @@ -1684,7 +1684,7 @@ TEST [[ a.<?b?> = 10 * 60 ]] [[ -global a.b: integer +global a.b: integer = 600 ]] TEST [[ @@ -1692,7 +1692,7 @@ a.<?b?>.c = 1 * 1 ]] [[ global a.b: { - c: integer, + c: integer = 1, } ]] @@ -1745,20 +1745,6 @@ print(b.<?x?>) [[ field A.x: unknown ]] -TEST [[ ----@class A ----@field x number ----@field y number - ----@type A<string, number> -local <?t?> -]] -[[ -local t: A<string, number> { - x: number, - y: number, -} -]] TEST [[ ---@return nil |