changeset 22930:84567584951f v8.2.2012

patch 8.2.2012: Vim9: confusing error message when using bool wrongly Commit: https://github.com/vim/vim/commit/d92cc130fbb1beacf6411ee5837545f46f9be90e Author: Bram Moolenaar <Bram@vim.org> Date: Wed Nov 18 17:17:15 2020 +0100 patch 8.2.2012: Vim9: confusing error message when using bool wrongly Problem: Vim9: confusing error message when using bool wrongly. Solution: Mention "Bool" instead of "Special". (closes https://github.com/vim/vim/issues/7323)
author Bram Moolenaar <Bram@vim.org>
date Wed, 18 Nov 2020 17:30:04 +0100
parents 401512a04eec
children 7b03a3108d09
files src/errors.h src/testdir/test_vim9_expr.vim src/typval.c src/version.c
diffstat 4 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/errors.h
+++ b/src/errors.h
@@ -301,3 +301,5 @@ EXTERN char e_cmd_mapping_must_end_with_
 	INIT(=N_("E1136: <Cmd> mapping must end with <CR> before second <Cmd>"));
 EXTERN char e_cmd_maping_must_not_include_str_key[]
 	INIT(= N_("E1137: <Cmd> mapping must not include %s key"));
+EXTERN char e_using_bool_as_number[]
+	INIT(= N_("E1138: Using a Bool as a Number"));
--- a/src/testdir/test_vim9_expr.vim
+++ b/src/testdir/test_vim9_expr.vim
@@ -1292,6 +1292,13 @@ func Test_expr5_fails()
   call CheckDefFailure(["var x = 'a' .. 0z32"], 'E1105:', 1)
   call CheckDefFailure(["var x = 'a' .. function('len')"], 'E1105:', 1)
   call CheckDefFailure(["var x = 'a' .. function('len', ['a'])"], 'E1105:', 1)
+
+  call CheckScriptFailure(['vim9script', 'var x = 1 + v:none'], 'E611:', 2)
+  call CheckScriptFailure(['vim9script', 'var x = 1 + v:null'], 'E611:', 2)
+  call CheckScriptFailure(['vim9script', 'var x = 1 + v:true'], 'E1138:', 2)
+  call CheckScriptFailure(['vim9script', 'var x = 1 + v:false'], 'E1138:', 2)
+  call CheckScriptFailure(['vim9script', 'var x = 1 + true'], 'E1138:', 2)
+  call CheckScriptFailure(['vim9script', 'var x = 1 + false'], 'E1138:', 2)
 endfunc
 
 func Test_expr5_fails_channel()
--- a/src/typval.c
+++ b/src/typval.c
@@ -213,7 +213,10 @@ tv_get_bool_or_number_chk(typval_T *varp
 	case VAR_SPECIAL:
 	    if (!want_bool && in_vim9script())
 	    {
-		emsg(_("E611: Using a Special as a Number"));
+		if (varp->v_type == VAR_BOOL)
+		    emsg(_(e_using_bool_as_number));
+		else
+		    emsg(_("E611: Using a Special as a Number"));
 		break;
 	    }
 	    return varp->vval.v_number == VVAL_TRUE ? 1 : 0;
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    2012,
+/**/
     2011,
 /**/
     2010,