summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changelog.md1
-rw-r--r--locale/en-us/script.lua2
-rw-r--r--locale/pt-br/script.lua2
-rw-r--r--locale/zh-cn/script.lua2
-rw-r--r--locale/zh-tw/script.lua2
-rw-r--r--script/parser/compile.lua18
6 files changed, 27 insertions, 0 deletions
diff --git a/changelog.md b/changelog.md
index a3464247..6376d8d2 100644
--- a/changelog.md
+++ b/changelog.md
@@ -2,6 +2,7 @@
## 3.5.3
* `FIX` [#1409](https://github.com/sumneko/lua-language-server/issues/1409)
+* `FIX` [#1422](https://github.com/sumneko/lua-language-server/issues/1422)
## 3.5.2
`2022-8-1`
diff --git a/locale/en-us/script.lua b/locale/en-us/script.lua
index 05a5c0d1..9135644b 100644
--- a/locale/en-us/script.lua
+++ b/locale/en-us/script.lua
@@ -269,6 +269,8 @@ PARSER_INDEX_IN_FUNC_NAME =
'The `[name]` form cannot be used in the name of a named function.'
PARSER_UNKNOWN_ATTRIBUTE =
'Local attribute should be `const` or `close`'
+PARSER_AMBIGUOUS_SYNTAX = -- TODO: need translate!
+'In Lua 5.1, the left brackets called by the function must be in the same line as the function.'
PARSER_LUADOC_MISS_CLASS_NAME =
'<class name> expected.'
PARSER_LUADOC_MISS_EXTENDS_SYMBOL =
diff --git a/locale/pt-br/script.lua b/locale/pt-br/script.lua
index 5e954d06..d1ae41b8 100644
--- a/locale/pt-br/script.lua
+++ b/locale/pt-br/script.lua
@@ -269,6 +269,8 @@ PARSER_INDEX_IN_FUNC_NAME =
'A forma `[name]` não pode ser usada em nome de uma função nomeada.'
PARSER_UNKNOWN_ATTRIBUTE =
'Atributo local deve ser `const` ou `close`'
+PARSER_AMBIGUOUS_SYNTAX = -- TODO: need translate!
+'In Lua 5.1, the left brackets called by the function must be in the same line as the function.'
PARSER_LUADOC_MISS_CLASS_NAME =
'Esperado <class name>.'
PARSER_LUADOC_MISS_EXTENDS_SYMBOL =
diff --git a/locale/zh-cn/script.lua b/locale/zh-cn/script.lua
index e839e92c..775400ec 100644
--- a/locale/zh-cn/script.lua
+++ b/locale/zh-cn/script.lua
@@ -269,6 +269,8 @@ PARSER_INDEX_IN_FUNC_NAME =
'命名函数的名称中不能使用 `[name]` 形式。'
PARSER_UNKNOWN_ATTRIBUTE =
'局部变量属性应该是 `const` 或 `close`'
+PARSER_AMBIGUOUS_SYNTAX =
+'在 Lua 5.1 中,函数调用的左括号必须与函数在同一行。'
PARSER_LUADOC_MISS_CLASS_NAME =
'缺少类名称。'
PARSER_LUADOC_MISS_EXTENDS_SYMBOL =
diff --git a/locale/zh-tw/script.lua b/locale/zh-tw/script.lua
index bb6ab94e..e234f5ae 100644
--- a/locale/zh-tw/script.lua
+++ b/locale/zh-tw/script.lua
@@ -269,6 +269,8 @@ PARSER_INDEX_IN_FUNC_NAME =
'命名函式的名稱中不能使用 `[name]` 形式。'
PARSER_UNKNOWN_ATTRIBUTE =
'區域變數屬性應該是 `const` 或 `close` 。'
+PARSER_AMBIGUOUS_SYNTAX = -- TODO: need translate!
+'在 Lua 5.1 中,函数调用的左括号必须与函数在同一行。'
PARSER_LUADOC_MISS_CLASS_NAME =
'缺少類別名稱。'
PARSER_LUADOC_MISS_EXTENDS_SYMBOL =
diff --git a/script/parser/compile.lua b/script/parser/compile.lua
index 8b2ae1e3..915a2764 100644
--- a/script/parser/compile.lua
+++ b/script/parser/compile.lua
@@ -1767,6 +1767,23 @@ local function addDummySelf(node, call)
tinsert(call.args, 1, self)
end
+local function checkAmbiguityCall(call, parenPos)
+ if State.version ~= 'Lua 5.1' then
+ return
+ end
+ local node = call.node
+ local nodeRow = guide.rowColOf(node.finish)
+ local callRow = guide.rowColOf(parenPos)
+ if nodeRow == callRow then
+ return
+ end
+ pushError {
+ type = 'AMBIGUOUS_SYNTAX',
+ start = parenPos,
+ finish = call.finish,
+ }
+end
+
local function parseSimple(node, funcName)
local lastMethod
while true do
@@ -1869,6 +1886,7 @@ local function parseSimple(node, funcName)
call.args = args
end
addDummySelf(node, call)
+ checkAmbiguityCall(call, startPos)
node.parent = call
node = call
elseif token == '{' then