Skip to content

Commit d92cc13

Browse files
committed
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 #7323)
1 parent 9950280 commit d92cc13

4 files changed

Lines changed: 15 additions & 1 deletion

File tree

src/errors.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,3 +301,5 @@ EXTERN char e_cmd_mapping_must_end_with_cr_before_second_cmd[]
301301
INIT(=N_("E1136: <Cmd> mapping must end with <CR> before second <Cmd>"));
302302
EXTERN char e_cmd_maping_must_not_include_str_key[]
303303
INIT(= N_("E1137: <Cmd> mapping must not include %s key"));
304+
EXTERN char e_using_bool_as_number[]
305+
INIT(= N_("E1138: Using a Bool as a Number"));

src/testdir/test_vim9_expr.vim

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,6 +1292,13 @@ func Test_expr5_fails()
12921292
call CheckDefFailure(["var x = 'a' .. 0z32"], 'E1105:', 1)
12931293
call CheckDefFailure(["var x = 'a' .. function('len')"], 'E1105:', 1)
12941294
call CheckDefFailure(["var x = 'a' .. function('len', ['a'])"], 'E1105:', 1)
1295+
1296+
call CheckScriptFailure(['vim9script', 'var x = 1 + v:none'], 'E611:', 2)
1297+
call CheckScriptFailure(['vim9script', 'var x = 1 + v:null'], 'E611:', 2)
1298+
call CheckScriptFailure(['vim9script', 'var x = 1 + v:true'], 'E1138:', 2)
1299+
call CheckScriptFailure(['vim9script', 'var x = 1 + v:false'], 'E1138:', 2)
1300+
call CheckScriptFailure(['vim9script', 'var x = 1 + true'], 'E1138:', 2)
1301+
call CheckScriptFailure(['vim9script', 'var x = 1 + false'], 'E1138:', 2)
12951302
endfunc
12961303

12971304
func Test_expr5_fails_channel()

src/typval.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,10 @@ tv_get_bool_or_number_chk(typval_T *varp, int *denote, int want_bool)
213213
case VAR_SPECIAL:
214214
if (!want_bool && in_vim9script())
215215
{
216-
emsg(_("E611: Using a Special as a Number"));
216+
if (varp->v_type == VAR_BOOL)
217+
emsg(_(e_using_bool_as_number));
218+
else
219+
emsg(_("E611: Using a Special as a Number"));
217220
break;
218221
}
219222
return varp->vval.v_number == VVAL_TRUE ? 1 : 0;

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2012,
753755
/**/
754756
2011,
755757
/**/

0 commit comments

Comments
 (0)