summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-10-22 21:22:58 +0200
committerBram Moolenaar <Bram@vim.org>2020-10-22 21:22:58 +0200
commit683581eb4980eda27d6438caab85c0a9cf551c24 (patch)
treeb8485f3863e4645d6feaab512c1d4f1b4f219504
parent081db1a66d17e46ac3b03b7514f11a004a35009a (diff)
patch 8.2.1891: Vim9: skipping over expression doesn't handle line breaksv8.2.1891
Problem: Vim9: skipping over expression doesn't handle line breaks. Solution: Pass evalarg to skip_expr(). (closes #7157)
-rw-r--r--src/eval.c4
-rw-r--r--src/ex_docmd.c9
-rw-r--r--src/misc1.c2
-rw-r--r--src/proto/eval.pro2
-rw-r--r--src/testdir/test_vim9_cmd.vim7
-rw-r--r--src/version.c2
-rw-r--r--src/vim9compile.c6
7 files changed, 22 insertions, 10 deletions
diff --git a/src/eval.c b/src/eval.c
index bb402dee94..6bc2b29d9c 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -368,12 +368,12 @@ eval_to_string_skip(
* Return FAIL for an error, OK otherwise.
*/
int
-skip_expr(char_u **pp)
+skip_expr(char_u **pp, evalarg_T *evalarg)
{
typval_T rettv;
*pp = skipwhite(*pp);
- return eval1(pp, &rettv, NULL);
+ return eval1(pp, &rettv, evalarg);
}
/*
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 1ccd38ec90..5c46411b94 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -640,7 +640,7 @@ do_cmdline(
struct dbg_stuff debug_saved; // saved things for debug mode
int initial_trylevel;
msglist_T **saved_msg_list = NULL;
- msglist_T *private_msg_list;
+ msglist_T *private_msg_list = NULL;
// "fgetline" and "cookie" passed to do_one_cmd()
char_u *(*cmd_getline)(int, void *, int, getline_opt_T);
@@ -664,7 +664,6 @@ do_cmdline(
// BufWritePost autocommands are executed after a write error.
saved_msg_list = msg_list;
msg_list = &private_msg_list;
- private_msg_list = NULL;
#endif
// It's possible to create an endless loop with ":execute", catch that
@@ -3256,7 +3255,7 @@ find_ex_command(
// When followed by "=" or "+=" then it is an assignment.
++emsg_silent;
- if (skip_expr(&after) == OK
+ if (skip_expr(&after, NULL) == OK
&& (*after == '='
|| (*after != NUL && after[1] == '=')))
eap->cmdidx = CMD_var;
@@ -4391,7 +4390,7 @@ expand_filename(
if (p[0] == '`' && p[1] == '=')
{
p += 2;
- (void)skip_expr(&p);
+ (void)skip_expr(&p, NULL);
if (*p == '`')
++p;
continue;
@@ -4666,7 +4665,7 @@ separate_nextcmd(exarg_T *eap)
else if (p[0] == '`' && p[1] == '=' && (eap->argt & EX_XFILE))
{
p += 2;
- (void)skip_expr(&p);
+ (void)skip_expr(&p, NULL);
}
#endif
diff --git a/src/misc1.c b/src/misc1.c
index bab9e680a7..058e8602db 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -1329,7 +1329,7 @@ expand_env_esc(
var = src;
src += 2;
- (void)skip_expr(&src);
+ (void)skip_expr(&src, NULL);
if (*src == '`')
++src;
len = src - var;
diff --git a/src/proto/eval.pro b/src/proto/eval.pro
index c32403fd0f..58ec79ce43 100644
--- a/src/proto/eval.pro
+++ b/src/proto/eval.pro
@@ -9,7 +9,7 @@ int eval_expr_valid_arg(typval_T *tv);
int eval_expr_typval(typval_T *expr, typval_T *argv, int argc, typval_T *rettv);
int eval_expr_to_bool(typval_T *expr, int *error);
char_u *eval_to_string_skip(char_u *arg, exarg_T *eap, int skip);
-int skip_expr(char_u **pp);
+int skip_expr(char_u **pp, evalarg_T *evalarg);
int skip_expr_concatenate(char_u **arg, char_u **start, char_u **end, evalarg_T *evalarg);
char_u *eval_to_string(char_u *arg, int convert);
char_u *eval_to_string_safe(char_u *arg, int use_sandbox);
diff --git a/src/testdir/test_vim9_cmd.vim b/src/testdir/test_vim9_cmd.vim
index ad3454d831..296aa55e6d 100644
--- a/src/testdir/test_vim9_cmd.vim
+++ b/src/testdir/test_vim9_cmd.vim
@@ -242,6 +242,13 @@ def Test_method_call_linebreak()
CheckScriptSuccess(lines)
enddef
+def Test_skipped_expr_linebreak()
+ if 0
+ var x = []
+ ->map({ -> 0})
+ endif
+enddef
+
def Test_dict_member()
var test: dict<list<number>> = {'data': [3, 1, 2]}
test.data->sort()
diff --git a/src/version.c b/src/version.c
index 2340ab8d1f..4b27b16ec9 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1891,
+/**/
1890,
/**/
1889,
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 58f4db9b72..45c35b2e4b 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -4385,7 +4385,11 @@ compile_expr1(char_u **arg, cctx_T *cctx, ppconst_T *ppconst)
// Ignore all kinds of errors when not producing code.
if (cctx->ctx_skip == SKIP_YES)
{
- skip_expr(arg);
+ evalarg_T evalarg;
+
+ CLEAR_FIELD(evalarg);
+ evalarg.eval_cctx = cctx;
+ skip_expr(arg, &evalarg);
return OK;
}