summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-09-05 16:36:23 +0200
committerBram Moolenaar <Bram@vim.org>2021-09-05 16:36:23 +0200
commit01dd6c3732a2f352d598e36336a65049614d7508 (patch)
treef04fc0464654d48e9dc81467215b2815578c50eb
parent2ddb89f8a94425cda1e5491efc80c1ccccb6e08e (diff)
downloadvim-git-01dd6c3732a2f352d598e36336a65049614d7508.tar.gz
patch 8.2.3404: Vim9: no error for white space before "("v8.2.3404
Problem: Vim9: no error for white space before "(". Solution: Give an error, like in a compiled function.
-rw-r--r--src/testdir/test_vim9_func.vim4
-rw-r--r--src/userfunc.c8
-rw-r--r--src/version.c2
3 files changed, 12 insertions, 2 deletions
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim
index f0c4c0d91..09f80e9d1 100644
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -467,6 +467,10 @@ def Test_call_varargs()
MyVarargs('one', 'two', 'three')->assert_equal('one,two,three')
enddef
+def Test_call_white_space()
+ CheckDefAndScriptFailure2(["call Test ('text')"], 'E476:', 'E1068:')
+enddef
+
def MyDefaultArgs(name = 'string'): string
return name
enddef
diff --git a/src/userfunc.c b/src/userfunc.c
index 4a2b05e0c..aa55bc85e 100644
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -4921,13 +4921,16 @@ ex_call(exarg_T *eap)
// Skip white space to allow ":call func ()". Not good, but required for
// backward compatibility.
startarg = skipwhite(arg);
- rettv.v_type = VAR_UNKNOWN; // clear_tv() uses this
-
if (*startarg != '(')
{
semsg(_(e_missing_paren), eap->arg);
goto end;
}
+ if (in_vim9script() && startarg > arg)
+ {
+ semsg(_(e_no_white_space_allowed_before_str_str), "(", eap->arg);
+ goto end;
+ }
/*
* When skipping, evaluate the function once, to find the end of the
@@ -4969,6 +4972,7 @@ ex_call(exarg_T *eap)
funcexe.partial = partial;
funcexe.selfdict = fudi.fd_dict;
funcexe.check_type = type;
+ rettv.v_type = VAR_UNKNOWN; // clear_tv() uses this
if (get_func_tv(name, -1, &rettv, &arg, &evalarg, &funcexe) == FAIL)
{
failed = TRUE;
diff --git a/src/version.c b/src/version.c
index 97467aab9..cfddf6bad 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 */
/**/
+ 3404,
+/**/
3403,
/**/
3402,