diff src/vim9compile.c @ 21828:af5db9b6d210

patch 8.2.1463: Vim9: list slice not supported yet Commit: https://github.com/vim/vim/commit/ed5918771fcf9877d8445e74c62ab1ce6b8e28c1 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Aug 15 22:14:53 2020 +0200 patch 8.2.1463: Vim9: list slice not supported yet Problem: Vim9: list slice not supported yet. Solution: Add support for list slicing.
author Bram Moolenaar <Bram@vim.org>
date Sat, 15 Aug 2020 22:15:03 +0200
parents ccad66ac6c3e
children d8422de73113
line wrap: on
line diff
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -3171,13 +3171,16 @@ compile_subscript(
 	    {
 		if (is_slice)
 		{
-		    emsg("Sorry, list slice not implemented yet");
-		    return FAIL;
+		    if (generate_instr_drop(cctx, ISN_LISTSLICE, 2) == FAIL)
+			return FAIL;
 		}
-		if ((*typep)->tt_type == VAR_LIST)
-		    *typep = (*typep)->tt_member;
-		if (generate_instr_drop(cctx, ISN_LISTINDEX, 1) == FAIL)
-		    return FAIL;
+		else
+		{
+		    if ((*typep)->tt_type == VAR_LIST)
+			*typep = (*typep)->tt_member;
+		    if (generate_instr_drop(cctx, ISN_LISTINDEX, 1) == FAIL)
+			return FAIL;
+		}
 	    }
 	    else
 	    {
@@ -7095,6 +7098,7 @@ delete_instr(isn_T *isn)
 	case ISN_EXECUTE:
 	case ISN_FOR:
 	case ISN_LISTINDEX:
+	case ISN_LISTSLICE:
 	case ISN_STRINDEX:
 	case ISN_STRSLICE:
 	case ISN_GETITEM: