Patch 8.2.2081

4 views
Skip to first unread message

Bram Moolenaar

unread,
Dec 2, 2020, 9:12:13 AM12/2/20
to vim...@googlegroups.com

Patch 8.2.2081
Problem: Vim9: cannot handle a linebreak after "=" in assignment.
Solution: Skip over linebreak. (closes #7407)
Files: src/vim9compile.c, src/testdir/test_vim9_assign.vim,
src/testdir/test_vim9_expr.vim


*** ../vim-8.2.2080/src/vim9compile.c 2020-12-02 14:24:26.973652266 +0100
--- src/vim9compile.c 2020-12-02 15:01:52.309955832 +0100
***************
*** 5670,5675 ****
--- 5670,5676 ----
else if (oplen > 0)
{
int is_const = FALSE;
+ char_u *wp;

// For "var = expr" evaluate the expression.
if (var_count == 0)
***************
*** 5694,5700 ****
if (new_local)
--cctx->ctx_locals.ga_len;
instr_count = instr->ga_len;
! p = skipwhite(op + oplen);
r = compile_expr0_ext(&p, cctx, &is_const);
if (new_local)
++cctx->ctx_locals.ga_len;
--- 5695,5704 ----
if (new_local)
--cctx->ctx_locals.ga_len;
instr_count = instr->ga_len;
! 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,5718 ****
// For "[var, var] = expr" get the "var_idx" item from the
// list.
if (generate_GETITEM(cctx, var_idx) == FAIL)
! return FAIL;
}

rhs_type = stack->ga_len == 0 ? &t_void
--- 5716,5722 ----
// For "[var, var] = expr" get the "var_idx" item from the
// list.
if (generate_GETITEM(cctx, var_idx) == FAIL)
! goto theend;
}

rhs_type = stack->ga_len == 0 ? &t_void
*** ../vim-8.2.2080/src/testdir/test_vim9_assign.vim 2020-11-30 21:39:59.476308440 +0100
--- src/testdir/test_vim9_assign.vim 2020-12-02 15:09:16.088402995 +0100
***************
*** 225,230 ****
--- 225,245 ----
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<number>
*** ../vim-8.2.2080/src/testdir/test_vim9_expr.vim 2020-11-25 21:30:07.086109185 +0100
--- src/testdir/test_vim9_expr.vim 2020-12-02 15:07:44.760719801 +0100
***************
*** 1940,1946 ****
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)

--- 1940,1945 ----
*** ../vim-8.2.2080/src/version.c 2020-12-02 14:24:26.973652266 +0100
--- src/version.c 2020-12-02 15:02:51.817745197 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2081,
/**/

--
Mental Floss prevents moral decay!

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages