2012/5/3 (Thu) 3:55:50 UTC+9 Bram Moolenaar:
> Yasohiro Matsumoto wrote:
> 
> > When passing same Dictionary/List to expand(), it breaks reference counter.
> > 
> > let o = {"a":{"b":"B"}}
> > call  extend(o, o)
> > echo o.a.b <= crash
> > 
> > https://gist.github.com/2578755
> > 
> > Please check and include.
> 
> Thanks for the fix!  Can you also write a test for this?

Hi Bram,

Patch modified and test added.
eval.c patch author is Thinca.
test patch author is me.
(I have got consent from Yasuhiro Matsumoto.)

Please check.

Regards,
--
Hirohito Higashi

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
diff -r 8201108e9cf0 src/eval.c
--- a/src/eval.c	Tue May 01 21:14:34 2012 +0200
+++ b/src/eval.c	Fri May 04 00:16:26 2012 +0900
@@ -10191,7 +10191,7 @@
 			EMSG2(_("E737: Key already exists: %s"), hi2->hi_key);
 			break;
 		    }
-		    else if (*action == 'f')
+		    else if (*action == 'f' && HI2DI(hi2) != di1)
 		    {
 			clear_tv(&di1->di_tv);
 			copy_tv(&HI2DI(hi2)->di_tv, &di1->di_tv);
diff -r 8201108e9cf0 src/testdir/test55.in
--- a/src/testdir/test55.in	Tue May 01 21:14:34 2012 +0200
+++ b/src/testdir/test55.in	Fri May 04 00:16:26 2012 +0900
@@ -352,6 +352,24 @@
 :let dict4copy = deepcopy(dict4)
 :$put =(l == lcopy)
 :$put =(dict4 == dict4copy)
+:"
+:" Pass the same List to extend()
+:let l = [1, 2, 3, 4, 5]
+:call extend(l, l)
+:$put =string(l)
+:"
+:" Pass the same Dict to extend()
+:let d = { 'a': {'b': 'B'}}
+:call extend(d, d)
+:$put =string(d)
+:"
+:" Pass the same Dict to extend() with "error"
+:try
+:  call extend(d, d, "error")
+:catch
+:  $put =v:exception[:15] . v:exception[-1:-1]
+:endtry
+:$put =string(d)
 :endfun
 :"
 :call Test(1, 2, [3, 4], {5: 6})  " This may take a while
diff -r 8201108e9cf0 src/testdir/test55.ok
--- a/src/testdir/test55.ok	Tue May 01 21:14:34 2012 +0200
+++ b/src/testdir/test55.ok	Fri May 04 00:16:26 2012 +0900
@@ -111,3 +111,7 @@
 0
 1
 1
+[1, 2, 3, 4, 5, 1, 2, 3, 4, 5]
+{'a': {'b': 'B'}}
+Vim(call):E737: a
+{'a': {'b': 'B'}}

Raspunde prin e-mail lui