]> granicus.if.org Git - vim/commitdiff
patch 8.2.0469: Vim9: no error for missing ] after list v8.2.0469
authorBram Moolenaar <Bram@vim.org>
Sat, 28 Mar 2020 20:38:06 +0000 (21:38 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 28 Mar 2020 20:38:06 +0000 (21:38 +0100)
Problem:    Vim9: no error for missing ] after list.
Solution:   Add error message. Add more tests.

src/globals.h
src/list.c
src/testdir/test_lambda.vim
src/testdir/test_vim9_expr.vim
src/userfunc.c
src/version.c

index f1538d62257c2046e6e8639864837584fbad4990..290f07dd5e7c16e6b33b11b95c2cf1e2905703ac 100644 (file)
@@ -1644,6 +1644,7 @@ EXTERN char e_func_deleted[]      INIT(= N_("E933: Function was deleted: %s"));
 EXTERN char e_dictkey[]                INIT(= N_("E716: Key not present in Dictionary: %s"));
 EXTERN char e_listreq[]                INIT(= N_("E714: List required"));
 EXTERN char e_listblobreq[]    INIT(= N_("E897: List or Blob required"));
+EXTERN char e_list_end[]       INIT(= N_("E697: Missing end of List ']': %s"));
 EXTERN char e_listdictarg[]    INIT(= N_("E712: Argument of %s must be a List or Dictionary"));
 EXTERN char e_listdictblobarg[]        INIT(= N_("E896: Argument of %s must be a List, Dictionary or Blob"));
 EXTERN char e_modulus[]                INIT(= N_("E804: Cannot use '%' with Float"));
index 518423b7146c76ed88846b2f213ecce4594b7ced..918626e1690f548e4334a37d78bb41fbc39e42a1 100644 (file)
@@ -1083,7 +1083,7 @@ get_list_tv(char_u **arg, typval_T *rettv, int evaluate, int do_error)
     if (**arg != ']')
     {
        if (do_error)
-           semsg(_("E697: Missing end of List ']': %s"), *arg);
+           semsg(_(e_list_end), *arg);
 failret:
        if (evaluate)
            list_free(l);
index 7fdfb876e410898c10f34d611be5420c69ee96f2..bc3d5ace7926c3635429b3684787736ce8b05de5 100644 (file)
@@ -62,7 +62,7 @@ endfunc
 function Test_lambda_fails()
   call assert_equal(3, {a, b -> a + b}(1, 2))
   call assert_fails('echo {a, a -> a + a}(1, 2)', 'E853:')
-  call assert_fails('echo {a, b -> a + b)}(1, 2)', 'E15:')
+  call assert_fails('echo {a, b -> a + b)}(1, 2)', 'E451:')
   echo assert_fails('echo 10->{a -> a + 2}', 'E107:')
 endfunc
 
index c9d50246dfe65ebb38e3f93bffe57364ac21e8bc..93626d5549fcba23170215e365f61da48a7656fe 100644 (file)
@@ -806,6 +806,12 @@ func Test_expr7_fails()
   call CheckDefFailure("let x = @", "E1002:")
   call CheckDefFailure("let x = @<", "E354:")
 
+  call CheckDefFailure("let x = [1, 2", "E697:")
+  call CheckDefFailure("let x = [notfound]", "E1001:")
+
+  call CheckDefFailure("let x = { -> 123) }", "E451:")
+  call CheckDefFailure("let x = 123->{x -> x + 5) }", "E451:")
+
   call CheckDefFailure("let x = &notexist", 'E113:')
   call CheckDefExecFailure("&grepprg = [343]", 'E1051:')
 
@@ -878,6 +884,7 @@ enddef
 
 func Test_expr7_trailing_fails()
   call CheckDefFailureList(['let l = [2]', 'l->{l -> add(l, 8)}'], 'E107')
+  call CheckDefFailureList(['let l = [2]', 'l->{l -> add(l, 8)} ()'], 'E274')
 endfunc
 
 func Test_expr_fails()
index 32b9fb5ad704b28f535ecf4d627aed1434514fc7..05e5b7f56d911b61fd26dbb2e99d509e652cb402 100644 (file)
@@ -350,7 +350,10 @@ get_lambda_tv(char_u **arg, typval_T *rettv, int evaluate)
     e = *arg;
     *arg = skipwhite(*arg);
     if (**arg != '}')
+    {
+       semsg(_("E451: Expected }: %s"), *arg);
        goto errret;
+    }
     ++*arg;
 
     if (evaluate)
index a4ffae0ab8e46ee28b7b74151c4b5053396ec4a7..8bf06a13c711aec062e98c2dbfc6420343fc0593 100644 (file)
@@ -738,6 +738,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    469,
 /**/
     468,
 /**/