Skip to content

Commit 7f3ed1f

Browse files
committed
Nesting of [[...]] is not allowed in Lua 5.1 .
fix #1805
1 parent be4dcc0 commit 7f3ed1f

File tree

6 files changed

+23
-0
lines changed

6 files changed

+23
-0
lines changed

changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* `FIX` [#1737]
1616
* `FIX` [#1751]
1717
* `FIX` [#1767]
18+
* `FIX` [#1805]
1819
* `FIX` [#1808]
1920
* `FIX` [#1811]
2021

@@ -23,6 +24,7 @@
2324
[#1737]: https://github.com/sumneko/lua-language-server/issues/1737
2425
[#1751]: https://github.com/sumneko/lua-language-server/issues/1751
2526
[#1767]: https://github.com/sumneko/lua-language-server/issues/1767
27+
[#1805]: https://github.com/sumneko/lua-language-server/issues/1805
2628
[#1808]: https://github.com/sumneko/lua-language-server/issues/1808
2729
[#1811]: https://github.com/sumneko/lua-language-server/issues/1811
2830

locale/en-us/script.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ PARSER_AMBIGUOUS_SYNTAX = -- TODO: need translate!
279279
'In Lua 5.1, the left brackets called by the function must be in the same line as the function.'
280280
PARSER_NEED_PAREN = -- TODO: need translate!
281281
'Need to add a pair of parentheses.'
282+
PARSER_NESTING_LONG_MARK =
283+
'Nesting of `[[...]]` is not allowed in Lua 5.1 .'
282284
PARSER_LUADOC_MISS_CLASS_NAME =
283285
'<class name> expected.'
284286
PARSER_LUADOC_MISS_EXTENDS_SYMBOL =

locale/pt-br/script.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ PARSER_AMBIGUOUS_SYNTAX = -- TODO: need translate!
279279
'In Lua 5.1, the left brackets called by the function must be in the same line as the function.'
280280
PARSER_NEED_PAREN = -- TODO: need translate!
281281
'需要添加一对括号。'
282+
PARSER_NESTING_LONG_MARK = -- TODO: need translate!
283+
'Nesting of `[[...]]` is not allowed in Lua 5.1 .'
282284
PARSER_LUADOC_MISS_CLASS_NAME =
283285
'Esperado <class name>.'
284286
PARSER_LUADOC_MISS_EXTENDS_SYMBOL =

locale/zh-cn/script.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ PARSER_AMBIGUOUS_SYNTAX =
279279
'在 Lua 5.1 中,函数调用的左括号必须与函数在同一行。'
280280
PARSER_NEED_PAREN =
281281
'需要添加一对括号。'
282+
PARSER_NESTING_LONG_MARK =
283+
'Lua 5.1 中不允许使用嵌套的 `[[...]]` 。'
282284
PARSER_LUADOC_MISS_CLASS_NAME =
283285
'缺少类名称。'
284286
PARSER_LUADOC_MISS_EXTENDS_SYMBOL =

locale/zh-tw/script.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ PARSER_AMBIGUOUS_SYNTAX = -- TODO: need translate!
279279
'在 Lua 5.1 中,函数调用的左括号必须与函数在同一行。'
280280
PARSER_NEED_PAREN = -- TODO: need translate!
281281
'需要添加一对括号。'
282+
PARSER_NESTING_LONG_MARK = -- TODO: need translate!
283+
'Nesting of `[[...]]` is not allowed in Lua 5.1 .'
282284
PARSER_LUADOC_MISS_CLASS_NAME =
283285
'缺少類別名稱。'
284286
PARSER_LUADOC_MISS_EXTENDS_SYMBOL =

script/parser/compile.lua

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,19 @@ local function resolveLongString(finishMark)
431431
: gsub('\r\n?', '\n')
432432
stringResult = result
433433
end
434+
if finishMark == ']]' and State.version == 'Lua 5.1' then
435+
local nestOffset = sfind(Lua, '[[', start, true)
436+
if nestOffset then
437+
fastForwardToken(nestOffset)
438+
local nestStartPos = getPosition(nestOffset, 'left')
439+
local nestFinishPos = getPosition(nestOffset + 1, 'right')
440+
pushError {
441+
type = 'NESTING_LONG_MARK',
442+
start = nestStartPos,
443+
finish = nestFinishPos,
444+
}
445+
end
446+
end
434447
fastForwardToken(finishOffset + #finishMark)
435448
if miss then
436449
local pos = getPosition(finishOffset - 1, 'right')

0 commit comments

Comments
 (0)