summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-07-10 21:50:41 +0200
committerBram Moolenaar <Bram@vim.org>2020-07-10 21:50:41 +0200
commita7eedf317a806fceec1ddd8f9bebed6e00be0ed2 (patch)
tree8eb9ea4372b7e8df11eb537523d39666eea0cc8a
parent11a5b19a8ce543c258832ac53d771047f4e1061d (diff)
patch 8.2.1175: Vim9: cannot split a line before ".member"v8.2.1175
Problem: Vim9: Cannot split a line before ".member". Solution: Check for ".member" after line break.
-rw-r--r--src/testdir/test_vim9_expr.vim8
-rw-r--r--src/version.c2
-rw-r--r--src/vim9compile.c26
3 files changed, 32 insertions, 4 deletions
diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim
index 83b7692090..1f4bde9123 100644
--- a/src/testdir/test_vim9_expr.vim
+++ b/src/testdir/test_vim9_expr.vim
@@ -1016,7 +1016,8 @@ def Test_expr7_list()
call CheckDefFailure(["let x = g:list_mixed[xxx]"], 'E1001:')
call CheckDefFailure(["let x = [1,2,3]"], 'E1069:')
call CheckDefExecFailure(["let x = g:list_mixed['xx']"], 'E39:')
- call CheckDefFailure(["let x = g:list_mixed[0"], 'E111:')
+ call CheckDefFailure(["let x = g:list_mixed["], 'E1097:')
+ call CheckDefFailure(["let x = g:list_mixed[0"], 'E1097:')
call CheckDefExecFailure(["let x = g:list_empty[3]"], 'E684:')
enddef
@@ -1135,6 +1136,11 @@ def Test_expr_member()
assert_equal(1, g:dict_one.one)
let d: dict<number> = g:dict_one
assert_equal(1, d['one'])
+ assert_equal(1, d[
+ 'one'
+ ])
+ assert_equal(1, d
+ .one)
# getting the one member should clear the dict after getting the item
assert_equal('one', #{one: 'one'}.one)
diff --git a/src/version.c b/src/version.c
index 3d8f86c640..ac5425ddd5 100644
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1175,
+/**/
1174,
/**/
1173,
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 93ab3c8c05..3c0336ac4a 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -2501,6 +2501,21 @@ may_get_next_line(char_u *whitep, char_u **arg, cctx_T *cctx)
return OK;
}
+/*
+ * Idem, and give an error when failed.
+ */
+ static int
+may_get_next_line_error(char_u *whitep, char_u **arg, cctx_T *cctx)
+{
+ if (may_get_next_line(whitep, arg, cctx) == FAIL)
+ {
+ emsg(_("E1097: line incomplete"));
+ return FAIL;
+ }
+ return OK;
+}
+
+
// Structure passed between the compile_expr* functions to keep track of
// constants that have been parsed but for which no code was produced yet. If
// possible expressions on these constants are applied at compile time. If
@@ -3588,8 +3603,11 @@ compile_subscript(
// If a following line starts with "->{" or "->X" advance to that
// line, so that a line break before "->" is allowed.
- if (next != NULL && next[0] == '-' && next[1] == '>'
- && (next[2] == '{' || ASCII_ISALPHA(next[2])))
+ // Also if a following line starts with ".x".
+ if (next != NULL &&
+ ((next[0] == '-' && next[1] == '>'
+ && (next[2] == '{' || ASCII_ISALPHA(next[2])))
+ || (next[0] == '.' && ASCII_ISALPHA(next[1]))))
{
next = next_line_from_context(cctx, TRUE);
if (next == NULL)
@@ -3672,11 +3690,13 @@ compile_subscript(
++p;
*arg = skipwhite(p);
- if (may_get_next_line(p, arg, cctx) == FAIL)
+ if (may_get_next_line_error(p, arg, cctx) == FAIL)
return FAIL;
if (compile_expr0(arg, cctx) == FAIL)
return FAIL;
+ if (may_get_next_line_error(p, arg, cctx) == FAIL)
+ return FAIL;
if (**arg != ']')
{
emsg(_(e_missbrac));