diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-12-21 11:34:01 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-12-21 11:34:01 +0800 |
commit | dba3476884f6ff53e0b0843fb77b42e5205161e1 (patch) | |
tree | 34769134813331093a5b768ef16e15179363944a /server | |
parent | 8dbca0ef1c2c0970b5674b408344ad4d3b65d2d7 (diff) | |
download | lua-language-server-dba3476884f6ff53e0b0843fb77b42e5205161e1.zip |
可以dump任何表
Diffstat (limited to 'server')
-rw-r--r-- | server/src/utility.lua | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/server/src/utility.lua b/server/src/utility.lua index 9c330ff7..1fda5406 100644 --- a/server/src/utility.lua +++ b/server/src/utility.lua @@ -20,14 +20,14 @@ local KEY = {} function table.dump(tbl) if type(tbl) ~= 'table' then - error('Must be a table') + return ('%q'):format(tbl) end local table_mark = {} local lines = {} lines[#lines+1] = '{' local function unpack(tbl, tab) if table_mark[tbl] then - error('Cyclic references are not allowed.') + return '<Circle Table>' end table_mark[tbl] = true local keys = {} @@ -41,7 +41,7 @@ function table.dump(tbl) elseif math_type(key) == 'integer' then KEY[key] = ('[%d]'):format(key) else - error('Key must be `string` or `integer`') + KEY[key] = ('<%s>'):format(key) end keys[#keys+1] = key end @@ -58,7 +58,7 @@ function table.dump(tbl) elseif tp == 'string' or tp == 'number' or tp == 'boolean' then lines[#lines+1] = ('%s%s = %q,'):format(TAB[tab+1], KEY[key], value) else - error(('Unsupport value type: [%s]'):format(tp)) + lines[#lines+1] = ('%s%s = <%s>,'):format(TAB[tab+1], KEY[key], value) end end end |