Skip to content

Commit be33769

Browse files
committed
fix wrong PARSER_NEED_PAREN
#1886
1 parent d493f5e commit be33769

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

script/parser/compile.lua

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2351,7 +2351,16 @@ local function parseFunction(isLocal, isAction)
23512351
return func
23522352
end
23532353

2354-
local function pushErrorNeedParen(source)
2354+
local function checkNeedParen(source)
2355+
local token = Tokens[Index + 1]
2356+
if token ~= '.'
2357+
and token ~= ':' then
2358+
return source
2359+
end
2360+
local exp = parseSimple(source, false)
2361+
if exp == source then
2362+
return exp
2363+
end
23552364
pushError {
23562365
type = 'NEED_PAREN',
23572366
start = source.start,
@@ -2370,6 +2379,7 @@ local function pushErrorNeedParen(source)
23702379
}
23712380
}
23722381
}
2382+
return exp
23732383
end
23742384

23752385
local function parseExpUnit()
@@ -2389,10 +2399,7 @@ local function parseExpUnit()
23892399
if not table then
23902400
return nil
23912401
end
2392-
local exp = parseSimple(table, false)
2393-
if exp ~= table then
2394-
pushErrorNeedParen(table)
2395-
end
2402+
local exp = checkNeedParen(table)
23962403
return exp
23972404
end
23982405

@@ -2401,10 +2408,7 @@ local function parseExpUnit()
24012408
if not string then
24022409
return nil
24032410
end
2404-
local exp = parseSimple(string, false)
2405-
if exp ~= string then
2406-
pushErrorNeedParen(string)
2407-
end
2411+
local exp = checkNeedParen(string)
24082412
return exp
24092413
end
24102414

@@ -2413,10 +2417,7 @@ local function parseExpUnit()
24132417
if not string then
24142418
return nil
24152419
end
2416-
local exp = parseSimple(string, false)
2417-
if exp ~= string then
2418-
pushErrorNeedParen(string)
2419-
end
2420+
local exp = checkNeedParen(string)
24202421
return exp
24212422
end
24222423

0 commit comments

Comments
 (0)