# HG changeset patch # User Bram Moolenaar # Date 1606918505 -3600 # Node ID 6a70803f4cbe6a2b1b56cad35bcc6e08d56ad11c # Parent fae4ecfc265322f28a868a18e188ff072f7b5c4d patch 8.2.2081: Vim9: cannot handle a linebreak after "=" in assignment Commit: https://github.com/vim/vim/commit/7f76494aac512b1d603d9be4132184241f43872c Author: Bram Moolenaar Date: Wed Dec 2 15:11:18 2020 +0100 patch 8.2.2081: Vim9: cannot handle a linebreak after "=" in assignment Problem: Vim9: cannot handle a linebreak after "=" in assignment. Solution: Skip over linebreak. (closes https://github.com/vim/vim/issues/7407) diff --git a/src/testdir/test_vim9_assign.vim b/src/testdir/test_vim9_assign.vim --- a/src/testdir/test_vim9_assign.vim +++ b/src/testdir/test_vim9_assign.vim @@ -225,6 +225,21 @@ def Test_assignment() END enddef +def Test_assign_linebreak() + var nr: number + nr = + 123 + assert_equal(123, nr) + + var n2: number + [nr, n2] = + [12, 34] + assert_equal(12, nr) + assert_equal(34, n2) + + CheckDefFailure(["var x = #"], 'E1097:', 2) +enddef + def Test_assign_index() # list of list var l1: list diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim --- a/src/testdir/test_vim9_expr.vim +++ b/src/testdir/test_vim9_expr.vim @@ -1940,7 +1940,6 @@ def Test_expr7_dict() CheckDefFailure(["var x = {'a': xxx}"], 'E1001:', 1) CheckDefFailure(["var x = {xx-x: 8}"], 'E1001:', 1) CheckDefFailure(["var x = #{a: 1, a: 2}"], 'E721:', 1) - CheckDefFailure(["var x = #"], 'E1015:', 1) CheckDefExecFailure(["var x = g:anint.member"], 'E715:', 1) CheckDefExecFailure(["var x = g:dict_empty.member"], 'E716:', 1) diff --git a/src/version.c b/src/version.c --- 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 */ /**/ + 2081, +/**/ 2080, /**/ 2079, diff --git a/src/vim9compile.c b/src/vim9compile.c --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -5670,6 +5670,7 @@ compile_assignment(char_u *arg, exarg_T else if (oplen > 0) { int is_const = FALSE; + char_u *wp; // For "var = expr" evaluate the expression. if (var_count == 0) @@ -5694,7 +5695,10 @@ compile_assignment(char_u *arg, exarg_T if (new_local) --cctx->ctx_locals.ga_len; instr_count = instr->ga_len; - p = skipwhite(op + oplen); + wp = op + oplen; + p = skipwhite(wp); + if (may_get_next_line_error(wp, &p, cctx) == FAIL) + goto theend; r = compile_expr0_ext(&p, cctx, &is_const); if (new_local) ++cctx->ctx_locals.ga_len; @@ -5712,7 +5716,7 @@ compile_assignment(char_u *arg, exarg_T // For "[var, var] = expr" get the "var_idx" item from the // list. if (generate_GETITEM(cctx, var_idx) == FAIL) - return FAIL; + goto theend; } rhs_type = stack->ga_len == 0 ? &t_void