diff src/eval.c @ 20871:65d9189d4dca v8.2.0987

patch 8.2.0987: Vim9: cannot assign to [var; var] Commit: https://github.com/vim/vim/commit/9af78769eeae0318e07aa8b6af4d6e2244481ca7 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jun 16 11:34:42 2020 +0200 patch 8.2.0987: Vim9: cannot assign to [var; var] Problem: Vim9: cannot assign to [var; var]. Solution: Assign rest of items to a list.
author Bram Moolenaar <Bram@vim.org>
date Tue, 16 Jun 2020 11:45:04 +0200
parents 876e16c48bd1
children 1693ca876049
line wrap: on
line diff
--- a/src/eval.c
+++ b/src/eval.c
@@ -3237,7 +3237,6 @@ eval_index(
 		if (range)
 		{
 		    list_T	*l;
-		    listitem_T	*item;
 
 		    if (n2 < 0)
 			n2 = len + n2;
@@ -3245,19 +3244,9 @@ eval_index(
 			n2 = len - 1;
 		    if (!empty2 && (n2 < 0 || n2 + 1 < n1))
 			n2 = -1;
-		    l = list_alloc();
+		    l = list_slice(rettv->vval.v_list, n1, n2);
 		    if (l == NULL)
 			return FAIL;
-		    for (item = list_find(rettv->vval.v_list, n1);
-							       n1 <= n2; ++n1)
-		    {
-			if (list_append_tv(l, &item->li_tv) == FAIL)
-			{
-			    list_free(l);
-			    return FAIL;
-			}
-			item = item->li_next;
-		    }
 		    clear_tv(rettv);
 		    rettv_list_set(rettv, l);
 		}