diff src/vim9compile.c @ 19461:08ef11a81daa v8.2.0288

patch 8.2.0288: Vim9: some float and blob operators not tested Commit: https://github.com/vim/vim/commit/0062c2d4f91caa2360933068ac46c55bdd303b53 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Feb 20 22:14:31 2020 +0100 patch 8.2.0288: Vim9: some float and blob operators not tested Problem: Vim9: some float and blob operators not tested. Solution: Add float and blob tests. Fix addition.
author Bram Moolenaar <Bram@vim.org>
date Thu, 20 Feb 2020 22:30:03 +0100
parents 655631882288
children f41e46f02c8c
line wrap: on
line diff
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -374,6 +374,8 @@ generate_two_op(cctx_T *cctx, char_u *op
     switch (*op)
     {
 	case '+': if (vartype != VAR_LIST && vartype != VAR_BLOB
+			  && type1->tt_type != VAR_UNKNOWN
+			  && type2->tt_type != VAR_UNKNOWN
 			  && check_number_or_float(
 				   type1->tt_type, type2->tt_type, op) == FAIL)
 		      return FAIL;
@@ -1074,9 +1076,16 @@ generate_MEMBER(cctx_T *cctx, char_u *na
 	return FAIL;
     isn->isn_arg.string = vim_strnsave(name, (int)len);
 
-    // change dict type to dict member type
+    // check for dict type
     type = ((type_T **)stack->ga_data)[stack->ga_len - 1];
-    ((type_T **)stack->ga_data)[stack->ga_len - 1] = type->tt_member;
+    if (type->tt_type != VAR_DICT && type != &t_any)
+    {
+	emsg(_(e_dictreq));
+	return FAIL;
+    }
+    // change dict type to dict member type
+    if (type->tt_type == VAR_DICT)
+	((type_T **)stack->ga_data)[stack->ga_len - 1] = type->tt_member;
 
     return OK;
 }
@@ -2370,7 +2379,8 @@ compile_subscript(
 		emsg(_(e_listreq));
 		return FAIL;
 	    }
-	    *typep = (*typep)->tt_member;
+	    if ((*typep)->tt_type == VAR_LIST)
+		*typep = (*typep)->tt_member;
 	}
 	else if (**arg == '.' && (*arg)[1] != '.')
 	{
@@ -2387,7 +2397,6 @@ compile_subscript(
 		semsg(_(e_syntax_at), *arg);
 		return FAIL;
 	    }
-	    // TODO: check type is dict
 	    if (generate_MEMBER(cctx, *arg, p - *arg) == FAIL)
 		return FAIL;
 	    *arg = p;
@@ -4964,6 +4973,10 @@ compile_def_function(ufunc_T *ufunc, int
 
 	    default:
 		    // Not recognized, execute with do_cmdline_cmd().
+		    // TODO:
+		    // CMD_echomsg
+		    // CMD_execute
+		    // etc.
 		    generate_EXEC(&cctx, line);
 		    line = (char_u *)"";
 		    break;