Skip to content

Commit 13bb2c6

Browse files
committed
fix #1422
1 parent 9b5ac53 commit 13bb2c6

File tree

6 files changed

+27
-0
lines changed

6 files changed

+27
-0
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## 3.5.3
44
* `FIX` [#1409](https://github.com/sumneko/lua-language-server/issues/1409)
5+
* `FIX` [#1422](https://github.com/sumneko/lua-language-server/issues/1422)
56

67
## 3.5.2
78
`2022-8-1`

locale/en-us/script.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ PARSER_INDEX_IN_FUNC_NAME =
269269
'The `[name]` form cannot be used in the name of a named function.'
270270
PARSER_UNKNOWN_ATTRIBUTE =
271271
'Local attribute should be `const` or `close`'
272+
PARSER_AMBIGUOUS_SYNTAX = -- TODO: need translate!
273+
'In Lua 5.1, the left brackets called by the function must be in the same line as the function.'
272274
PARSER_LUADOC_MISS_CLASS_NAME =
273275
'<class name> expected.'
274276
PARSER_LUADOC_MISS_EXTENDS_SYMBOL =

locale/pt-br/script.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ PARSER_INDEX_IN_FUNC_NAME =
269269
'A forma `[name]` não pode ser usada em nome de uma função nomeada.'
270270
PARSER_UNKNOWN_ATTRIBUTE =
271271
'Atributo local deve ser `const` ou `close`'
272+
PARSER_AMBIGUOUS_SYNTAX = -- TODO: need translate!
273+
'In Lua 5.1, the left brackets called by the function must be in the same line as the function.'
272274
PARSER_LUADOC_MISS_CLASS_NAME =
273275
'Esperado <class name>.'
274276
PARSER_LUADOC_MISS_EXTENDS_SYMBOL =

locale/zh-cn/script.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ PARSER_INDEX_IN_FUNC_NAME =
269269
'命名函数的名称中不能使用 `[name]` 形式。'
270270
PARSER_UNKNOWN_ATTRIBUTE =
271271
'局部变量属性应该是 `const` 或 `close`'
272+
PARSER_AMBIGUOUS_SYNTAX =
273+
'在 Lua 5.1 中,函数调用的左括号必须与函数在同一行。'
272274
PARSER_LUADOC_MISS_CLASS_NAME =
273275
'缺少类名称。'
274276
PARSER_LUADOC_MISS_EXTENDS_SYMBOL =

locale/zh-tw/script.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ PARSER_INDEX_IN_FUNC_NAME =
269269
'命名函式的名稱中不能使用 `[name]` 形式。'
270270
PARSER_UNKNOWN_ATTRIBUTE =
271271
'區域變數屬性應該是 `const` 或 `close` 。'
272+
PARSER_AMBIGUOUS_SYNTAX = -- TODO: need translate!
273+
'在 Lua 5.1 中,函数调用的左括号必须与函数在同一行。'
272274
PARSER_LUADOC_MISS_CLASS_NAME =
273275
'缺少類別名稱。'
274276
PARSER_LUADOC_MISS_EXTENDS_SYMBOL =

script/parser/compile.lua

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1767,6 +1767,23 @@ local function addDummySelf(node, call)
17671767
tinsert(call.args, 1, self)
17681768
end
17691769

1770+
local function checkAmbiguityCall(call, parenPos)
1771+
if State.version ~= 'Lua 5.1' then
1772+
return
1773+
end
1774+
local node = call.node
1775+
local nodeRow = guide.rowColOf(node.finish)
1776+
local callRow = guide.rowColOf(parenPos)
1777+
if nodeRow == callRow then
1778+
return
1779+
end
1780+
pushError {
1781+
type = 'AMBIGUOUS_SYNTAX',
1782+
start = parenPos,
1783+
finish = call.finish,
1784+
}
1785+
end
1786+
17701787
local function parseSimple(node, funcName)
17711788
local lastMethod
17721789
while true do
@@ -1869,6 +1886,7 @@ local function parseSimple(node, funcName)
18691886
call.args = args
18701887
end
18711888
addDummySelf(node, call)
1889+
checkAmbiguityCall(call, startPos)
18721890
node.parent = call
18731891
node = call
18741892
elseif token == '{' then

0 commit comments

Comments
 (0)