summaryrefslogtreecommitdiff
path: root/script/parser
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2023-02-07 20:12:26 +0800
committer最萌小汐 <sumneko@hotmail.com>2023-02-07 20:12:26 +0800
commitbe33769c27a26119ad909fad0a0975b2f89c775c (patch)
treea1c8dac93d4dae94b5ab4c2325d076d022156fa7 /script/parser
parentd493f5e8bd2479d16fd44502d057db169749c561 (diff)
downloadlua-language-server-be33769c27a26119ad909fad0a0975b2f89c775c.zip
fix wrong `PARSER_NEED_PAREN`
#1886
Diffstat (limited to 'script/parser')
-rw-r--r--script/parser/compile.lua27
1 files changed, 14 insertions, 13 deletions
diff --git a/script/parser/compile.lua b/script/parser/compile.lua
index f8808d5a..2a95e6a9 100644
--- a/script/parser/compile.lua
+++ b/script/parser/compile.lua
@@ -2351,7 +2351,16 @@ local function parseFunction(isLocal, isAction)
return func
end
-local function pushErrorNeedParen(source)
+local function checkNeedParen(source)
+ local token = Tokens[Index + 1]
+ if token ~= '.'
+ and token ~= ':' then
+ return source
+ end
+ local exp = parseSimple(source, false)
+ if exp == source then
+ return exp
+ end
pushError {
type = 'NEED_PAREN',
start = source.start,
@@ -2370,6 +2379,7 @@ local function pushErrorNeedParen(source)
}
}
}
+ return exp
end
local function parseExpUnit()
@@ -2389,10 +2399,7 @@ local function parseExpUnit()
if not table then
return nil
end
- local exp = parseSimple(table, false)
- if exp ~= table then
- pushErrorNeedParen(table)
- end
+ local exp = checkNeedParen(table)
return exp
end
@@ -2401,10 +2408,7 @@ local function parseExpUnit()
if not string then
return nil
end
- local exp = parseSimple(string, false)
- if exp ~= string then
- pushErrorNeedParen(string)
- end
+ local exp = checkNeedParen(string)
return exp
end
@@ -2413,10 +2417,7 @@ local function parseExpUnit()
if not string then
return nil
end
- local exp = parseSimple(string, false)
- if exp ~= string then
- pushErrorNeedParen(string)
- end
+ local exp = checkNeedParen(string)
return exp
end