Patch 8.2.3058

1 view
Skip to first unread message

Bram Moolenaar

unread,
Jun 26, 2021, 4:01:20 PM6/26/21
to vim...@googlegroups.com

Patch 8.2.3058 (after 8.2.3056)
Problem: Vim9: cannot use ternary operator in parenthesis.
Solution: Do not use "==" for a default argument value. (closes #8462)
Files: src/userfunc.c, src/testdir/test_vim9_func.vim


*** ../vim-8.2.3057/src/userfunc.c 2021-06-26 19:25:42.744311276 +0200
--- src/userfunc.c 2021-06-26 21:47:35.934484091 +0200
***************
*** 266,278 ****
}
else
{
arg = p;
p = one_function_arg(p, newargs, argtypes, types_optional,
evalarg, FALSE, skip);
if (p == arg)
break;

! if (*skipwhite(p) == '=' && default_args != NULL)
{
typval_T rettv;

--- 266,283 ----
}
else
{
+ char_u *np;
+
arg = p;
p = one_function_arg(p, newargs, argtypes, types_optional,
evalarg, FALSE, skip);
if (p == arg)
break;

! // Recognize " = expr" but not " == expr". A lambda can have
! // "(a = expr" but "(a == expr" is not a lambda.
! np = skipwhite(p);
! if (*np == '=' && np[1] != '=' && default_args != NULL)
{
typval_T rettv;

*** ../vim-8.2.3057/src/testdir/test_vim9_func.vim 2021-06-26 19:25:42.744311276 +0200
--- src/testdir/test_vim9_func.vim 2021-06-26 21:49:14.742394823 +0200
***************
*** 924,929 ****
--- 924,936 ----
CheckDefAndScriptFailure(lines, 'E1172:')

lines =<< trim END
+ var a = 0
+ var b = (a == 0 ? 1 : 2)
+ assert_equal(1, b)
+ END
+ CheckDefAndScriptSuccess(lines)
+
+ lines =<< trim END
def ShadowLocal()
var one = 1
var l = [1, 2, 3]
*** ../vim-8.2.3057/src/version.c 2021-06-26 21:20:59.791632565 +0200
--- src/version.c 2021-06-26 21:51:43.602238681 +0200
***************
*** 757,758 ****
--- 757,760 ----
{ /* Add new patch number below this line */
+ /**/
+ 3058,
/**/

--
Change is inevitable, except from a vending machine.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages