summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/src/core/hover.lua14
-rw-r--r--server/test/hover/init.lua18
2 files changed, 28 insertions, 4 deletions
diff --git a/server/src/core/hover.lua b/server/src/core/hover.lua
index b328ac00..e99becdc 100644
--- a/server/src/core/hover.lua
+++ b/server/src/core/hover.lua
@@ -267,7 +267,13 @@ local function unpackTable(value)
key = ('[*%s]'):format(key:getType())
elseif math.type(key) == 'integer' then
key = ('[%03d]'):format(key)
- elseif kType ~= 'string' then
+ elseif kType == 'string' then
+ if key:find '^%d' or key:find '[^%w_]' then
+ key = ('[%q]'):format(key)
+ end
+ elseif key == '' then
+ key = '[*any]'
+ else
key = ('[%s]'):format(key)
end
@@ -277,9 +283,9 @@ local function unpackTable(value)
or vType == 'number'
or vType == 'string'
then
- lines[#lines+1] = ('%s: %s = %q,'):format(key, child:getType(), child:getLiteral())
+ lines[#lines+1] = ('%s: %s = %q'):format(key, child:getType(), child:getLiteral())
else
- lines[#lines+1] = ('%s: %s,'):format(key, child:getType())
+ lines[#lines+1] = ('%s: %s'):format(key, child:getType())
end
end)
if #lines == 0 then
@@ -297,7 +303,7 @@ local function unpackTable(value)
if line == '[*any]: any' then
goto CONTINUE
end
- cleaned[#cleaned+1] = ' ' .. line
+ cleaned[#cleaned+1] = ' ' .. line .. ','
:: CONTINUE ::
end
diff --git a/server/test/hover/init.lua b/server/test/hover/init.lua
index 642b8216..8187f7d3 100644
--- a/server/test/hover/init.lua
+++ b/server/test/hover/init.lua
@@ -285,16 +285,34 @@ local <?t?> = {
[5.5] = 4,
[{}] = 5,
[function () end] = 6,
+ ["b"] = 7,
+ ["012"] = 8,
}
]]
[[
local t: {
+ ["012"]: number = 8,
[*function]: number = 6,
[*table]: number = 5,
[001]: number = 2,
[5.5]: number = 4,
[true]: number = 3,
a: number = 1,
+ b: number = 7,
+}
+]]
+
+TEST [[
+local <?t?> = {}
+t[#t+1] = 1
+t[#t+1] = 1
+
+local any = collectgarbage()
+t[any] = any
+]]
+[[
+local t: {
+ [*number]: number = 1,
}
]]