Skip to content

Commit

Permalink
special goto for LuaJIT
Browse files Browse the repository at this point in the history
fix #1895
  • Loading branch information
sumneko committed Feb 10, 2023
1 parent 0dafb45 commit d4583fe
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
## 3.6.11
* `CHG` completion: don't show loading process
* `FIX` [#1886]
* `FIX` [#1895]

[#1886]: https://github.com/LuaLS/lua-language-server/issues/1886
[#1895]: https://github.com/LuaLS/lua-language-server/issues/1895

## 3.6.10
`2023-2-7`
Expand Down
22 changes: 17 additions & 5 deletions script/parser/compile.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1379,12 +1379,24 @@ local function parseNumber()
return result
end

local function isKeyWord(word)
local function isKeyWord(word, nextToken)
if KeyWord[word] then
return true
end
if word == 'goto' then
return State.version ~= 'Lua 5.1'
if State.version == 'Lua 5.1' then
return false
end
if State.version == 'LuaJIT' then
if not nextToken then
return true
end
if CharMapWord[ssub(nextToken, 1, 1)] then
return true
end
return false
end
return true
end
return false
end
Expand All @@ -1410,7 +1422,7 @@ local function parseName(asAction)
finish = finishPos,
}
end
if isKeyWord(word) then
if isKeyWord(word, Tokens[Index]) then
pushError {
type = 'KEYWORD',
start = startPos,
Expand Down Expand Up @@ -1491,7 +1503,7 @@ local function parseExpList(mini)
break
end
local nextToken = peekWord()
if isKeyWord(nextToken)
if isKeyWord(nextToken, Tokens[Index + 2])
and nextToken ~= 'function'
and nextToken ~= 'true'
and nextToken ~= 'false'
Expand Down Expand Up @@ -2223,7 +2235,7 @@ local function parseParams(params)
finish = getPosition(Tokens[Index] + #token - 1, 'right'),
}
end
if isKeyWord(token) then
if isKeyWord(token, Tokens[Index + 2]) then
pushError {
type = 'KEYWORD',
start = getPosition(Tokens[Index], 'left'),
Expand Down

0 comments on commit d4583fe

Please sign in to comment.