summaryrefslogtreecommitdiff
path: root/script-beta
diff options
context:
space:
mode:
Diffstat (limited to 'script-beta')
-rw-r--r--script-beta/core/hover/label.lua12
-rw-r--r--script-beta/parser/guide.lua14
2 files changed, 16 insertions, 10 deletions
diff --git a/script-beta/core/hover/label.lua b/script-beta/core/hover/label.lua
index c3607415..cc2cdd09 100644
--- a/script-beta/core/hover/label.lua
+++ b/script-beta/core/hover/label.lua
@@ -22,9 +22,9 @@ local function asValue(source, title)
local type = 'any'
local literal = ''
local cont
- local values = vm.getInfers(source)
- if values then
- for _, value in ipairs(values) do
+ local infers = vm.getInfers(source)
+ if infers then
+ for _, value in ipairs(infers) do
local src = value.source
local tp = value.type
class = guide.mergeTypes {class, vm.getClass(src)}
@@ -54,10 +54,12 @@ local function asValue(source, title)
pack[#pack+1] = name .. ':'
if cont then
type = nil
+ end
+ if class == 'any' then
+ pack[#pack+1] = type
else
- type = type or 'any'
+ pack[#pack+1] = class
end
- pack[#pack+1] = class or type
if literal ~= '' then
pack[#pack+1] = '='
pack[#pack+1] = literal
diff --git a/script-beta/parser/guide.lua b/script-beta/parser/guide.lua
index 863d828e..835e62ba 100644
--- a/script-beta/parser/guide.lua
+++ b/script-beta/parser/guide.lua
@@ -1846,16 +1846,15 @@ function m.allocInfer(o)
-- TODO
assert(o.type)
if type(o.type) == 'table' then
- local values = {}
+ local infers = {}
for i = 1, #o.type do
- local sub = {
+ infers[i] = {
type = o.type[i],
value = o.value,
source = o.source,
}
- values[i] = sub
end
- return values
+ return infers
else
return {
[1] = o,
@@ -1865,9 +1864,11 @@ end
function m.mergeTypes(infers)
local types = {}
+ local mark = {}
for i = 1, #infers do
for tp in infers[i]:gmatch '[^|]+' do
- if not types[tp] and tp ~= 'any' then
+ if not mark[tp] and tp ~= 'any' then
+ mark[tp] = true
types[#types+1] = tp
end
end
@@ -2733,6 +2734,9 @@ function m.cleanInfers(infers)
local mark = {}
for i = 1, #infers do
local infer = infers[i]
+ if not infer then
+ return
+ end
local key = ('%s|%p'):format(infer.type, infer.source)
if mark[key] then
infers[i] = infers[#infers]