summaryrefslogtreecommitdiffstats
path: root/src/evalvars.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-07-23 13:11:37 +0200
committerBram Moolenaar <Bram@vim.org>2020-07-23 13:11:37 +0200
commit63be3d4ba01d565e645d8bf7f4dc900fc9011534 (patch)
tree52375a30387a79924200a31e33a5a574bb9202dd /src/evalvars.c
parentc69950ac17225d07f973b39d5b0eb94291077808 (diff)
patch 8.2.1274: Vim9: no error for missing white space at script levelv8.2.1274
Problem: Vim9: no error for missing white space in assignment at script level. Solution: Check for white space. (closes #6495)
Diffstat (limited to 'src/evalvars.c')
-rw-r--r--src/evalvars.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/evalvars.c b/src/evalvars.c
index e2469b0e82..564c65b8aa 100644
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -698,12 +698,13 @@ ex_let(exarg_T *eap)
int i;
int var_count = 0;
int semicolon = 0;
- char_u op[2];
+ char_u op[4];
char_u *argend;
int first = TRUE;
int concat;
int has_assign;
int flags = eap->cmdidx == CMD_const ? LET_IS_CONST : 0;
+ int vim9script = in_vim9script();
// detect Vim9 assignment without ":let" or ":const"
if (eap->arg == eap->cmd)
@@ -725,11 +726,11 @@ ex_let(exarg_T *eap)
// ":let" without "=": list variables
if (*arg == '[')
emsg(_(e_invarg));
- else if (expr[0] == '.')
- emsg(_("E985: .= is not supported with script version 2"));
+ else if (expr[0] == '.' && expr[1] == '=')
+ emsg(_("E985: .= is not supported with script version >= 2"));
else if (!ends_excmd2(eap->cmd, arg))
{
- if (in_vim9script())
+ if (vim9script)
{
// Vim9 declaration ":let var: type"
arg = vim9_declare_scriptvar(eap, arg);
@@ -775,6 +776,7 @@ ex_let(exarg_T *eap)
else
{
evalarg_T evalarg;
+ int len = 1;
rettv.v_type = VAR_UNKNOWN;
i = FAIL;
@@ -787,13 +789,25 @@ ex_let(exarg_T *eap)
if (vim_strchr((char_u *)"+-*/%.", *expr) != NULL)
{
op[0] = *expr; // +=, -=, *=, /=, %= or .=
+ ++len;
if (expr[0] == '.' && expr[1] == '.') // ..=
+ {
++expr;
+ ++len;
+ }
}
- expr = skipwhite(expr + 2);
+ expr += 2;
}
else
- expr = skipwhite(expr + 1);
+ ++expr;
+
+ if (vim9script && (!VIM_ISWHITE(*argend) || !VIM_ISWHITE(*expr)))
+ {
+ vim_strncpy(op, expr - len, len);
+ semsg(_(e_white_both), op);
+ i = FAIL;
+ }
+ expr = skipwhite(expr);
if (eap->skip)
++emsg_skip;
@@ -817,7 +831,7 @@ ex_let(exarg_T *eap)
else if (i != FAIL)
{
(void)ex_let_vars(eap->arg, &rettv, FALSE, semicolon, var_count,
- flags, op);
+ flags, op);
clear_tv(&rettv);
}
}