Patch 8.2.3060 (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.3059/src/userfunc.c 2021-06-26 22:17:32.259003328 +0200
--- src/userfunc.c 2021-06-26 22:19:33.998771013 +0200
***************
*** 275,283 ****
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;
--- 275,284 ----
break;
// Recognize " = expr" but not " == expr". A lambda can have
! // "(a = expr" but "(a == expr" and "(a =~ expr" are not a lambda.
np = skipwhite(p);
! if (*np == '=' && np[1] != '=' && np[1] != '~'
! && default_args != NULL)
{
typval_T rettv;
*** ../vim-8.2.3059/src/testdir/test_vim9_func.vim 2021-06-26 21:51:58.514221840 +0200
--- src/testdir/test_vim9_func.vim 2021-06-26 22:21:17.386576525 +0200
***************
*** 927,932 ****
--- 927,935 ----
var a = 0
var b = (a == 0 ? 1 : 2)
assert_equal(1, b)
+ var txt = 'a'
+ b = (txt =~ 'x' ? 1 : 2)
+ assert_equal(2, b)
END
CheckDefAndScriptSuccess(lines)
*** ../vim-8.2.3059/src/version.c 2021-06-26 22:17:32.259003328 +0200
--- src/version.c 2021-06-26 22:20:42.102642642 +0200
***************
*** 757,758 ****
--- 757,760 ----
{ /* Add new patch number below this line */
+ /**/
+ 3060,
/**/
--
Those who live by the sword get shot by those who don't.
/// 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 ///