Skip to content

Commit ee619e5

Browse files
committed
patch 8.2.0469: Vim9: no error for missing ] after list
Problem: Vim9: no error for missing ] after list. Solution: Add error message. Add more tests.
1 parent 7c003aa commit ee619e5

6 files changed

Lines changed: 15 additions & 2 deletions

File tree

src/globals.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,6 +1644,7 @@ EXTERN char e_func_deleted[] INIT(= N_("E933: Function was deleted: %s"));
16441644
EXTERN char e_dictkey[] INIT(= N_("E716: Key not present in Dictionary: %s"));
16451645
EXTERN char e_listreq[] INIT(= N_("E714: List required"));
16461646
EXTERN char e_listblobreq[] INIT(= N_("E897: List or Blob required"));
1647+
EXTERN char e_list_end[] INIT(= N_("E697: Missing end of List ']': %s"));
16471648
EXTERN char e_listdictarg[] INIT(= N_("E712: Argument of %s must be a List or Dictionary"));
16481649
EXTERN char e_listdictblobarg[] INIT(= N_("E896: Argument of %s must be a List, Dictionary or Blob"));
16491650
EXTERN char e_modulus[] INIT(= N_("E804: Cannot use '%' with Float"));

src/list.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,7 @@ get_list_tv(char_u **arg, typval_T *rettv, int evaluate, int do_error)
10831083
if (**arg != ']')
10841084
{
10851085
if (do_error)
1086-
semsg(_("E697: Missing end of List ']': %s"), *arg);
1086+
semsg(_(e_list_end), *arg);
10871087
failret:
10881088
if (evaluate)
10891089
list_free(l);

src/testdir/test_lambda.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ endfunc
6262
function Test_lambda_fails()
6363
call assert_equal(3, {a, b -> a + b}(1, 2))
6464
call assert_fails('echo {a, a -> a + a}(1, 2)', 'E853:')
65-
call assert_fails('echo {a, b -> a + b)}(1, 2)', 'E15:')
65+
call assert_fails('echo {a, b -> a + b)}(1, 2)', 'E451:')
6666
echo assert_fails('echo 10->{a -> a + 2}', 'E107:')
6767
endfunc
6868

src/testdir/test_vim9_expr.vim

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,12 @@ func Test_expr7_fails()
806806
call CheckDefFailure("let x = @", "E1002:")
807807
call CheckDefFailure("let x = @<", "E354:")
808808

809+
call CheckDefFailure("let x = [1, 2", "E697:")
810+
call CheckDefFailure("let x = [notfound]", "E1001:")
811+
812+
call CheckDefFailure("let x = { -> 123) }", "E451:")
813+
call CheckDefFailure("let x = 123->{x -> x + 5) }", "E451:")
814+
809815
call CheckDefFailure("let x = &notexist", 'E113:')
810816
call CheckDefExecFailure("&grepprg = [343]", 'E1051:')
811817

@@ -878,6 +884,7 @@ enddef
878884

879885
func Test_expr7_trailing_fails()
880886
call CheckDefFailureList(['let l = [2]', 'l->{l -> add(l, 8)}'], 'E107')
887+
call CheckDefFailureList(['let l = [2]', 'l->{l -> add(l, 8)} ()'], 'E274')
881888
endfunc
882889

883890
func Test_expr_fails()

src/userfunc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,10 @@ get_lambda_tv(char_u **arg, typval_T *rettv, int evaluate)
350350
e = *arg;
351351
*arg = skipwhite(*arg);
352352
if (**arg != '}')
353+
{
354+
semsg(_("E451: Expected }: %s"), *arg);
353355
goto errret;
356+
}
354357
++*arg;
355358

356359
if (evaluate)

src/version.c

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

739739
static int included_patches[] =
740740
{ /* Add new patch number below this line */
741+
/**/
742+
469,
741743
/**/
742744
468,
743745
/**/

0 commit comments

Comments
 (0)