changeset 19842:e4ade28bfaf7 v8.2.0477

patch 8.2.0477: Vim9: error messages not tested Commit: https://github.com/vim/vim/commit/c58164c5cff9845f3bf7cfcd75ace43208829388 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Mar 29 18:40:30 2020 +0200 patch 8.2.0477: Vim9: error messages not tested Problem: Vim9: error messages not tested. Solution: Add more tests.
author Bram Moolenaar <Bram@vim.org>
date Sun, 29 Mar 2020 18:45:03 +0200
parents ff9fa9cc6e2e
children 00d850cecb84
files src/testdir/test_vim9_expr.vim src/version.c src/vim9execute.c
diffstat 3 files changed, 29 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/testdir/test_vim9_expr.vim
+++ b/src/testdir/test_vim9_expr.vim
@@ -728,6 +728,13 @@ def Test_expr7_dict()
   let val = 1
   assert_equal(g:dict_one, {key: val})
 
+  call CheckDefFailure("let x = #{8: 8}", 'E1014:')
+  call CheckDefFailure("let x = #{xxx}", 'E720:')
+  call CheckDefFailure("let x = #{xxx: 1", 'E722:')
+  call CheckDefFailure("let x = #{xxx: 1,", 'E723:')
+  call CheckDefFailure("let x = {'a': xxx}", 'E1001:')
+  call CheckDefFailure("let x = {xxx: 8}", 'E1001:')
+  call CheckDefFailure("let x = #{a: 1, a: 2}", 'E721:')
   call CheckDefExecFailure("let x = g:anint.member", 'E715:')
   call CheckDefExecFailure("let x = g:dict_empty.member", 'E716:')
 enddef
@@ -750,6 +757,8 @@ def Test_expr7_environment()
   " environment variable
   assert_equal('testvar', $TESTVAR)
   assert_equal('', $ASDF_ASD_XXX)
+
+  call CheckDefFailure("let x = $$$", 'E1002:')
 enddef
 
 def Test_expr7_register()
@@ -802,6 +811,9 @@ func Test_expr7_fails()
 
   call CheckDefFailure("let x = -'xx'", "E1030:")
   call CheckDefFailure("let x = +'xx'", "E1030:")
+  call CheckDefFailure("let x = -0z12", "E974:")
+  call CheckDefExecFailure("let x = -[8]", "E39:")
+  call CheckDefExecFailure("let x = -{'a': 1}", "E39:")
 
   call CheckDefFailure("let x = @", "E1002:")
   call CheckDefFailure("let x = @<", "E354:")
--- a/src/version.c
+++ b/src/version.c
@@ -739,6 +739,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    477,
+/**/
     476,
 /**/
     475,
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -1612,7 +1612,21 @@ call_def_function(
 
 	    case ISN_NEGATENR:
 		tv = STACK_TV_BOT(-1);
-		tv->vval.v_number = -tv->vval.v_number;
+		if (tv->v_type != VAR_NUMBER
+#ifdef FEAT_FLOAT
+			&& tv->v_type != VAR_FLOAT
+#endif
+			)
+		{
+		    emsg(_(e_number_exp));
+		    goto failed;
+		}
+#ifdef FEAT_FLOAT
+		if (tv->v_type == VAR_FLOAT)
+		    tv->vval.v_float = -tv->vval.v_float;
+		else
+#endif
+		    tv->vval.v_number = -tv->vval.v_number;
 		break;
 
 	    case ISN_CHECKNR: