diff src/vim9execute.c @ 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 aa4cbdb676cd
children 846fbbacce3a
line wrap: on
line diff
--- 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: