diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-06-26 22:22:38 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-06-26 22:22:38 +0200 |
commit | 98f9a5f4cbe6061e09bccf6074afe0a88a504219 (patch) | |
tree | 30d7aea4efa97e7222d810d5035f9d38f763c807 | |
parent | e3ffaa6b7c2d53ab53da933ec91382d003cf9a12 (diff) | |
download | vim-git-98f9a5f4cbe6061e09bccf6074afe0a88a504219.tar.gz |
patch 8.2.3060: Vim9: cannot use ternary operator in parenthesisv8.2.3060
Problem: Vim9: cannot use ternary operator in parenthesis.
Solution: Do not use "=~" for a default argument value. (closes #8462)
-rw-r--r-- | src/testdir/test_vim9_func.vim | 3 | ||||
-rw-r--r-- | src/userfunc.c | 5 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 8 insertions, 2 deletions
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim index 563b7bab8..4816cb667 100644 --- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -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) diff --git a/src/userfunc.c b/src/userfunc.c index c8d08bb45..4756bf9d3 100644 --- a/src/userfunc.c +++ b/src/userfunc.c @@ -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; diff --git a/src/version.c b/src/version.c index 7fbd6d0b1..069d8abaa 100644 --- a/src/version.c +++ b/src/version.c @@ -756,6 +756,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 3060, +/**/ 3059, /**/ 3058, |