Patch 7.4.1607
Problem: Comparing a function that exists on two dicts is not backwards
compatible. (Thinca)
Solution: Only compare the function, not what the partial adds.
Files: src/eval.c, src/testdir/test_alot.vim, src/testdir/test_expr.vim
*** ../vim-7.4.1606/src/eval.c 2016-03-19 18:52:14.934587197 +0100
--- src/eval.c 2016-03-19 19:18:50.725839117 +0100
***************
*** 4555,4587 ****
else if (rettv->v_type == VAR_FUNC || var2.v_type == VAR_FUNC
|| rettv->v_type == VAR_PARTIAL || var2.v_type == VAR_PARTIAL)
{
! if (rettv->v_type != var2.v_type
! || (type != TYPE_EQUAL && type != TYPE_NEQUAL))
{
! if (rettv->v_type != var2.v_type)
! EMSG(_("E693: Can only compare Funcref with Funcref"));
! else
! EMSG(_("E694: Invalid operation for Funcrefs"));
clear_tv(rettv);
clear_tv(&var2);
return FAIL;
}
! else if (rettv->v_type == VAR_PARTIAL)
! {
! /* Partials are only equal when identical. */
! n1 = rettv->vval.v_partial != NULL
! && rettv->vval.v_partial == var2.vval.v_partial;
! }
! else
! {
! /* Compare two Funcrefs for being equal or unequal. */
! if (rettv->vval.v_string == NULL
! || var2.vval.v_string == NULL)
! n1 = FALSE;
! else
! n1 = STRCMP(rettv->vval.v_string,
! var2.vval.v_string) == 0;
! }
if (type == TYPE_NEQUAL)
n1 = !n1;
}
--- 4555,4568 ----
else if (rettv->v_type == VAR_FUNC || var2.v_type == VAR_FUNC
|| rettv->v_type == VAR_PARTIAL || var2.v_type == VAR_PARTIAL)
{
! if (type != TYPE_EQUAL && type != TYPE_NEQUAL)
{
! EMSG(_("E694: Invalid operation for Funcrefs"));
clear_tv(rettv);
clear_tv(&var2);
return FAIL;
}
! n1 = tv_equal(rettv, &var2, FALSE, FALSE);
if (type == TYPE_NEQUAL)
n1 = !n1;
}
***************
*** 6203,6208 ****
--- 6184,6202 ----
static int recursive_cnt = 0; /* catch recursive loops */
int r;
+ /* For VAR_FUNC and VAR_PARTIAL only compare the function name. */
+ if ((tv1->v_type == VAR_FUNC
+ || (tv1->v_type == VAR_PARTIAL && tv1->vval.v_partial != NULL))
+ && (tv2->v_type == VAR_FUNC
+ || (tv2->v_type == VAR_PARTIAL && tv2->vval.v_partial != NULL)))
+ {
+ s1 = tv1->v_type == VAR_FUNC ? tv1->vval.v_string
+ : tv1->vval.v_partial->pt_name;
+ s2 = tv2->v_type == VAR_FUNC ? tv2->vval.v_string
+ : tv2->vval.v_partial->pt_name;
+ return (s1 != NULL && s2 != NULL && STRCMP(s1, s2) == 0);
+ }
+
if (tv1->v_type != tv2->v_type)
return FALSE;
***************
*** 6234,6248 ****
--recursive_cnt;
return r;
- case VAR_FUNC:
- return (tv1->vval.v_string != NULL
- && tv2->vval.v_string != NULL
- && STRCMP(tv1->vval.v_string, tv2->vval.v_string) == 0);
-
- case VAR_PARTIAL:
- return tv1->vval.v_partial != NULL
- && tv1->vval.v_partial == tv2->vval.v_partial;
-
case VAR_NUMBER:
return tv1->vval.v_number == tv2->vval.v_number;
--- 6228,6233 ----
***************
*** 6266,6271 ****
--- 6251,6258 ----
#ifdef FEAT_JOB_CHANNEL
return tv1->vval.v_channel == tv2->vval.v_channel;
#endif
+ case VAR_FUNC:
+ case VAR_PARTIAL:
case VAR_UNKNOWN:
break;
}
*** ../vim-7.4.1606/src/testdir/test_alot.vim 2016-03-15 23:10:26.412712095
+0100
--- src/testdir/test_alot.vim 2016-03-19 19:05:13.826408885 +0100
***************
*** 5,10 ****
--- 5,11 ----
source test_cursor_func.vim
source test_delete.vim
source test_ex_undo.vim
+ source test_expr.vim
source test_expand.vim
source test_feedkeys.vim
source test_file_perm.vim
*** ../vim-7.4.1606/src/testdir/test_expr.vim 2016-03-19 19:37:34.586049968
+0100
--- src/testdir/test_expr.vim 2016-03-19 19:22:02.375828831 +0100
***************
*** 0 ****
--- 1,23 ----
+ " Tests for expressions.
+
+ func Test_equal()
+ let base = {}
+ func base.method()
+ return 1
+ endfunc
+ func base.other() dict
+ return 1
+ endfunc
+ let instance = copy(base)
+ call assert_true(base.method == instance.method)
+ call assert_true([base.method] == [instance.method])
+ call assert_true(base.other == instance.other)
+ call assert_true([base.other] == [instance.other])
+
+ call assert_false(base.method == base.other)
+ call assert_false([base.method] == [base.other])
+ call assert_false(base.method == instance.other)
+ call assert_false([base.method] == [instance.other])
+
+ call assert_fails('echo base.method > instance.method')
+ endfunc
*** ../vim-7.4.1606/src/version.c 2016-03-19 18:52:14.938587155 +0100
--- src/version.c 2016-03-19 19:30:36.770432953 +0100
***************
*** 750,751 ****
--- 750,753 ----
{ /* Add new patch number below this line */
+ /**/
+ 1607,
/**/
--
>From "know your smileys":
:~) A man with a tape recorder up his nose
/// Bram Moolenaar -- [email protected] -- 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 ///
--
--
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
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.