0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 8.2.3060: Vim9: cannot use ternary operator in parenthesis

Problem:    Vim9: cannot use ternary operator in parenthesis.
Solution:   Do not use "=~" for a default argument value.  (closes #8462)
This commit is contained in:
Bram Moolenaar
2021-06-26 22:22:38 +02:00
parent e3ffaa6b7c
commit 98f9a5f4cb
3 changed files with 8 additions and 2 deletions

View File

@@ -927,6 +927,9 @@ def Test_call_lambda_args()
var a = 0 var a = 0
var b = (a == 0 ? 1 : 2) var b = (a == 0 ? 1 : 2)
assert_equal(1, b) assert_equal(1, b)
var txt = 'a'
b = (txt =~ 'x' ? 1 : 2)
assert_equal(2, b)
END END
CheckDefAndScriptSuccess(lines) CheckDefAndScriptSuccess(lines)

View File

@@ -275,9 +275,10 @@ get_function_args(
break; break;
// Recognize " = expr" but not " == expr". A lambda can have // Recognize " = expr" but not " == expr". A lambda can have
// "(a = expr" but "(a == expr" is not a lambda. // "(a = expr" but "(a == expr" and "(a =~ expr" are not a lambda.
np = skipwhite(p); np = skipwhite(p);
if (*np == '=' && np[1] != '=' && default_args != NULL) if (*np == '=' && np[1] != '=' && np[1] != '~'
&& default_args != NULL)
{ {
typval_T rettv; typval_T rettv;

View File

@@ -755,6 +755,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
3060,
/**/ /**/
3059, 3059,
/**/ /**/