summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2023-02-10 16:01:17 +0800
committer最萌小汐 <sumneko@hotmail.com>2023-02-10 16:01:17 +0800
commit4b0d634a27ae188c98f839736bad1b8514952467 (patch)
tree1152d131fe33306b0b753ed20d799119829add53 /script
parent5e112de9cbf4627038036fdfa41e9cf890d74e1d (diff)
downloadlua-language-server-4b0d634a27ae188c98f839736bad1b8514952467.zip
fix #1889
Diffstat (limited to 'script')
-rw-r--r--script/config/template.lua1
-rw-r--r--script/core/diagnostics/missing-return.lua2
-rw-r--r--script/core/diagnostics/unreachable-code.lua2
-rw-r--r--script/parser/compile.lua6
-rw-r--r--script/parser/guide.lua2
-rw-r--r--script/vm/tracer.lua2
6 files changed, 9 insertions, 6 deletions
diff --git a/script/config/template.lua b/script/config/template.lua
index e93ffa08..7a4d3f1b 100644
--- a/script/config/template.lua
+++ b/script/config/template.lua
@@ -210,6 +210,7 @@ local template = {
'assert',
'error',
'type',
+ 'os.exit',
}
),
['Lua.runtime.meta'] = Type.String >> '${version} ${language} ${encoding}',
diff --git a/script/core/diagnostics/missing-return.lua b/script/core/diagnostics/missing-return.lua
index 7333e5e3..2b5c90d2 100644
--- a/script/core/diagnostics/missing-return.lua
+++ b/script/core/diagnostics/missing-return.lua
@@ -7,7 +7,7 @@ local await = require 'await'
---@param block parser.object
---@return boolean
local function hasReturn(block)
- if block.hasReturn or block.hasError then
+ if block.hasReturn or block.hasExit then
return true
end
if block.type == 'if' then
diff --git a/script/core/diagnostics/unreachable-code.lua b/script/core/diagnostics/unreachable-code.lua
index 4f0a38b7..cbffe4db 100644
--- a/script/core/diagnostics/unreachable-code.lua
+++ b/script/core/diagnostics/unreachable-code.lua
@@ -23,7 +23,7 @@ end
---@param block parser.object
---@return boolean
local function hasReturn(block)
- if block.hasReturn or block.hasError then
+ if block.hasReturn or block.hasExit then
return true
end
if block.type == 'if' then
diff --git a/script/parser/compile.lua b/script/parser/compile.lua
index 7cc6f36b..917a68a4 100644
--- a/script/parser/compile.lua
+++ b/script/parser/compile.lua
@@ -118,6 +118,7 @@ local Specials = {
['assert'] = true,
['error'] = true,
['type'] = true,
+ ['os.exit'] = true,
}
local UnarySymbol = {
@@ -2899,14 +2900,15 @@ local function compileExpAsAction(exp)
end
if exp.type == 'call' then
- if exp.node.special == 'error' 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.hasError = true
+ block.hasExit = true
break
end
end
diff --git a/script/parser/guide.lua b/script/parser/guide.lua
index 0b6de77d..ec5746c1 100644
--- a/script/parser/guide.lua
+++ b/script/parser/guide.lua
@@ -72,7 +72,7 @@ local type = type
---@field hasGoTo? true
---@field hasReturn? true
---@field hasBreak? true
----@field hasError? true
+---@field hasExit? true
---@field [integer] parser.object|any
---@field package _root parser.object
diff --git a/script/vm/tracer.lua b/script/vm/tracer.lua
index 6ce57d5c..a13d00e1 100644
--- a/script/vm/tracer.lua
+++ b/script/vm/tracer.lua
@@ -369,7 +369,7 @@ local lookIntoChild = util.switch()
local neverReturn = subBlock.hasReturn
or subBlock.hasGoTo
or subBlock.hasBreak
- or subBlock.hasError
+ or subBlock.hasExit
if neverReturn then
mergedNode = true
else