eval/typval_encode: Fix infinite loop

Occurs when trying to dump a partial with attached self dictionary which
references that partial. “Infinite” loop should normally result in Neovim killed
by OOM killer.

Also moved the place when partials are unreferenced by clear_tv: from
…FUNC_START to …FUNC_END.
This commit is contained in:
ZyX
2016-12-25 23:29:35 +03:00
parent affa3c2baa
commit 759e736b0a
4 changed files with 134 additions and 39 deletions

View File

@@ -9,6 +9,7 @@ local redir_exec = helpers.redir_exec
local funcs = helpers.funcs
local write_file = helpers.write_file
local NIL = helpers.NIL
local source = helpers.source
describe('string() function', function()
before_each(clear)
@@ -137,6 +138,18 @@ describe('string() function', function()
it('dumps references to script functions', function()
eq('function(\'<SNR>1_Test2\')', eval('string(Test2_f)'))
end)
it('dumps partials with self referencing a partial', function()
source([[
function TestDict() dict
endfunction
let d = {}
let TestDictRef = function('TestDict', d)
let d.tdr = TestDictRef
]])
eq("\nE724: unable to correctly dump variable with self-referencing container\nfunction('TestDict', {'tdr': function('TestDict', {E724@1})})",
redir_exec('echo string(d.tdr)'))
end)
end)
describe('used to represent lists', function()