summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--script/parser/newparser.lua4
-rw-r--r--script/vm/compiler.lua2
-rw-r--r--test/type_inference/init.lua11
3 files changed, 14 insertions, 3 deletions
diff --git a/script/parser/newparser.lua b/script/parser/newparser.lua
index 8b5e6ee8..e226417f 100644
--- a/script/parser/newparser.lua
+++ b/script/parser/newparser.lua
@@ -1749,13 +1749,13 @@ local function addDummySelf(node, call)
parent = call,
}
end
- local self = createLocal {
+ local self = {
+ type = 'self',
start = node.colon.start,
finish = node.colon.finish,
parent = call.args,
[1] = 'self',
}
- self.type = 'self'
tinsert(call.args, 1, self)
end
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua
index bbc6a333..7b6531aa 100644
--- a/script/vm/compiler.lua
+++ b/script/vm/compiler.lua
@@ -731,7 +731,7 @@ local function compileLocalBase(source)
local hasMarkParam
if source.type == 'self' and not hasMarkDoc then
hasMarkParam = true
- if source.parent.parent.type == 'call' then
+ if source.parent.type == 'callargs' then
-- obj:func(...)
vm.setNode(source, vm.compileNode(source.parent.parent.node.node))
else
diff --git a/test/type_inference/init.lua b/test/type_inference/init.lua
index 7b5fb332..df45dd9d 100644
--- a/test/type_inference/init.lua
+++ b/test/type_inference/init.lua
@@ -1471,3 +1471,14 @@ TEST 'A' [[
---@type A
local <?x?> = nil
]]
+
+TEST 'A' [[
+---@class A
+---@field b B
+local mt
+
+function mt:f()
+ self.b:x()
+ print(<?self?>)
+end
+]]