summaryrefslogtreecommitdiff
path: root/script/parser/compile.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2023-03-09 14:54:49 +0800
committer最萌小汐 <sumneko@hotmail.com>2023-03-09 14:54:49 +0800
commita9fe326bb74a35501748fe1b265d9dbf268cfe88 (patch)
tree89c275f7367d2af2c431623318444ec1ac7c5a8e /script/parser/compile.lua
parentd7d44a727087337638b3fe8ff0a45a12945b2d03 (diff)
downloadlua-language-server-a9fe326bb74a35501748fe1b265d9dbf268cfe88.zip
support `x or error(...)`
fix #1945
Diffstat (limited to 'script/parser/compile.lua')
-rw-r--r--script/parser/compile.lua27
1 files changed, 15 insertions, 12 deletions
diff --git a/script/parser/compile.lua b/script/parser/compile.lua
index 917a68a4..a33fe09b 100644
--- a/script/parser/compile.lua
+++ b/script/parser/compile.lua
@@ -1974,6 +1974,12 @@ local function parseSimple(node, funcName)
and node.node == lastMethod then
lastMethod = nil
end
+ if node.type == 'call' then
+ if node.node.special == 'error'
+ or node.node.special == 'os.exit' then
+ node.hasExit = true
+ end
+ end
if node == lastMethod then
if funcName then
lastMethod = nil
@@ -2899,18 +2905,15 @@ local function compileExpAsAction(exp)
end
end
- if exp.type == 'call' then
- if exp.node.special == 'error'
- or exp.node.special == 'os.exit' then
- for i = #Chunk, 1, -1 do
- local block = Chunk[i]
- if block.type == 'ifblock'
- or block.type == 'elseifblock'
- or block.type == 'elseblock'
- or block.type == 'function' then
- block.hasExit = true
- break
- end
+ if exp.hasExit then
+ for i = #Chunk, 1, -1 do
+ local block = Chunk[i]
+ if block.type == 'ifblock'
+ or block.type == 'elseifblock'
+ or block.type == 'elseblock'
+ or block.type == 'function' then
+ block.hasExit = true
+ break
end
end
return exp