]> granicus.if.org Git - vim/commitdiff
patch 8.2.3060: Vim9: cannot use ternary operator in parenthesis v8.2.3060
authorBram Moolenaar <Bram@vim.org>
Sat, 26 Jun 2021 20:22:38 +0000 (22:22 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 26 Jun 2021 20:22:38 +0000 (22:22 +0200)
Problem:    Vim9: cannot use ternary operator in parenthesis.
Solution:   Do not use "=~" for a default argument value.  (closes #8462)

src/testdir/test_vim9_func.vim
src/userfunc.c
src/version.c

index 563b7bab8ca57a9498800ec8e5ad699dab11557d..4816cb6674afbc653f1840c343d78f5f9848430e 100644 (file)
@@ -927,6 +927,9 @@ def Test_call_lambda_args()
       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)
 
index c8d08bb45cfe1e49de853609ab2920c02006e026..4756bf9d3a0ad0c1be9361dd248492948b2cbcdf 100644 (file)
@@ -275,9 +275,10 @@ get_function_args(
                break;
 
            // 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);
-           if (*np == '=' && np[1] != '=' && default_args != NULL)
+           if (*np == '=' && np[1] != '=' && np[1] != '~'
+                                                      && default_args != NULL)
            {
                typval_T        rettv;
 
index 7fbd6d0b18104b03cf7be19c0ae98cc97c59f4b4..069d8abaae00a32a240482ee616169b1913388e9 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3060,
 /**/
     3059,
 /**/