]> granicus.if.org Git - vim/commitdiff
patch 8.2.2012: Vim9: confusing error message when using bool wrongly v8.2.2012
authorBram Moolenaar <Bram@vim.org>
Wed, 18 Nov 2020 16:17:15 +0000 (17:17 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 18 Nov 2020 16:17:15 +0000 (17:17 +0100)
Problem:    Vim9: confusing error message when using bool wrongly.
Solution:   Mention "Bool" instead of "Special". (closes #7323)

src/errors.h
src/testdir/test_vim9_expr.vim
src/typval.c
src/version.c

index 969301f9c4228854d2a153dbadcc95b39b813261..5ba6d52be5f7b20bd68469621b148a38dc137504 100644 (file)
@@ -301,3 +301,5 @@ EXTERN char e_cmd_mapping_must_end_with_cr_before_second_cmd[]
        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"));
index 63bfdd8040210e52149c049e8ef7756c55a38a58..b7897fe7cb4201bc5b6606dbb997c56e5232e277 100644 (file)
@@ -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()
index 7c55d3a5e1ee21fba740d21e1e6ae1810de96c02..0e2513aee39d7d2b363f86396a3b15dafd45f5fe 100644 (file)
@@ -213,7 +213,10 @@ tv_get_bool_or_number_chk(typval_T *varp, int *denote, int want_bool)
        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;
index 80d2af9db1ee4ca3fd06d437352388b14768aa58..0f0ccda25adc7397e4a0bec3be6fe52ba87a6e8f 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2012,
 /**/
     2011,
 /**/