Strange behavior while displaying recursive

117 views
Skip to first unread message

mattn

unread,
Oct 13, 2014, 11:14:24 AM10/13/14
to vim...@googlegroups.com
---------------
let a = {}
let a["a"] = a
echo a
{'a': {...}}
---------------

This is OK.

---------------
let a = {}
echo [a,a,a]
[{}, {...}, {...}]
---------------

This is NG. Should be [{}, {}, {}]

---------------
echo repeat([[]], 3)
[[],[...],[...]]
---------------

This is also NG. Should be [[], [], []]
Below is a patch to fix this.

https://gist.github.com/mattn/0e0f100a347ec88be19e

- Yasuhiro Matsumoto

Bram Moolenaar

unread,
Oct 15, 2014, 6:57:10 AM10/15/14
to mattn, vim...@googlegroups.com
I'm not quite sure this is right. Consider this:

let a = {"one": "yes", "two": "yes", "three": "yes"}
echo [a,a,a]

Before the change it would output:
[{'one': 'yes', 'two': 'yes', 'three': 'yes'}, {...}, {...}]

After the change:
[{'one': 'yes', 'two': 'yes', 'three': 'yes'}, {'one': 'yes', 'two': 'yes', 'thr
ee': 'yes'}, {'one': 'yes', 'two': 'yes', 'three': 'yes'}]

It repeats the same thing several times.

What we could do is to avoid the "..." when the list or dict is empty.

--
This sentence is not sure that it exists, but if it does, it will
certainly consider the possibility that other sentences exist.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

mattn

unread,
Oct 15, 2014, 8:35:45 AM10/15/14
to vim...@googlegroups.com, matt...@gmail.com
I'm thinking, string(x) is possible to eval if it don't have recursive references.
Anyone, how do you think?
Reply all
Reply to author
Forward
0 new messages