summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-06-15 15:36:03 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-06-15 15:36:03 +0800
commit96b4e0ba089c717aa5455a7f6fcf6caee863a74e (patch)
treee82bd7e57cf641d3e2a37892e7f5c892cab41bbf /script
parent98fe538e564bac10e5df65c31e20b8dc3317e87d (diff)
downloadlua-language-server-96b4e0ba089c717aa5455a7f6fcf6caee863a74e.zip
resolve #1094 infer type by `error`
Diffstat (limited to 'script')
-rw-r--r--script/parser/guide.lua1
-rw-r--r--script/parser/newparser.lua11
-rw-r--r--script/vm/runner.lua1
3 files changed, 13 insertions, 0 deletions
diff --git a/script/parser/guide.lua b/script/parser/guide.lua
index 83321bac..2894f673 100644
--- a/script/parser/guide.lua
+++ b/script/parser/guide.lua
@@ -65,6 +65,7 @@ local type = type
---@field hasGoTo? true
---@field hasReturn? true
---@field hasBreak? true
+---@field hasError? true
---@field _root parser.object
---@class guide
diff --git a/script/parser/newparser.lua b/script/parser/newparser.lua
index fa728c8b..c7e9256a 100644
--- a/script/parser/newparser.lua
+++ b/script/parser/newparser.lua
@@ -2818,6 +2818,17 @@ local function compileExpAsAction(exp)
end
if exp.type == 'call' then
+ if exp.node.special == 'error' then
+ for i = #Chunk, 1, -1 do
+ local block = Chunk[i]
+ if block.type == 'ifblock'
+ or block.type == 'elseifblock'
+ or block.type == 'else' then
+ block.hasError = true
+ break
+ end
+ end
+ end
return exp
end
diff --git a/script/vm/runner.lua b/script/vm/runner.lua
index e7851b49..5d561677 100644
--- a/script/vm/runner.lua
+++ b/script/vm/runner.lua
@@ -153,6 +153,7 @@ function mt:_lookInto(action, topNode, outNode)
local neverReturn = subBlock.hasReturn
or subBlock.hasGoTo
or subBlock.hasBreak
+ or subBlock.hasError
if not neverReturn then
blockNodes[#blockNodes+1] = blockNode
end