]> granicus.if.org Git - vim/commitdiff
patch 8.2.2081: Vim9: cannot handle a linebreak after "=" in assignment v8.2.2081
authorBram Moolenaar <Bram@vim.org>
Wed, 2 Dec 2020 14:11:18 +0000 (15:11 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 2 Dec 2020 14:11:18 +0000 (15:11 +0100)
Problem:    Vim9: cannot handle a linebreak after "=" in assignment.
Solution:   Skip over linebreak. (closes #7407)

src/testdir/test_vim9_assign.vim
src/testdir/test_vim9_expr.vim
src/version.c
src/vim9compile.c

index 7658d8303ae4b8018a159f99136a89be7f0c334e..1d8a86f115c15bca4c13ed4efc4e21395c6c2b2b 100644 (file)
@@ -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<number>
index 57307a27edd70892868cf315baabb5088ccbc8e8..d93751e623e22bf57a40c60b90af32e95a337d8c 100644 (file)
@@ -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)
 
index e3d5b6eb938c3c4da57bd431ef0ce3b0a25832cb..a81299dd1b1f0a71fbc4463b7f66b79a12612007 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2081,
 /**/
     2080,
 /**/
index 5b5f8f1af3ac5c4361b3b2736d659efe72e92236..db5e5c3530d41b5944218928d0507dea164449be 100644 (file)
@@ -5670,6 +5670,7 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
            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 *eap, cmdidx_T cmdidx, cctx_T *cctx)
                    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 *eap, cmdidx_T cmdidx, cctx_T *cctx)
                    // 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