# HG changeset patch # User Bram Moolenaar # Date 1594474204 -7200 # Node ID 71bd2f9adb61a1321b5f8e7abc673cb17ba4de09 # Parent f90a8e001d61ac8a8eb62dadbc555e2eb6abed84 patch 8.2.1182: Vim9: no check for whitespace after comma in lambda Commit: https://github.com/vim/vim/commit/914e7eaa67f8d816e15fb4a1180e6bece88d9742 Author: Bram Moolenaar Date: Sat Jul 11 15:20:48 2020 +0200 patch 8.2.1182: Vim9: no check for whitespace after comma in lambda Problem: Vim9: no check for whitespace after comma in lambda. Solution: Give error if white space is missing. diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim --- a/src/testdir/test_vim9_expr.vim +++ b/src/testdir/test_vim9_expr.vim @@ -1067,10 +1067,11 @@ def Test_expr7_list_vim9script() enddef def Test_expr7_lambda() - " lambda let La = { -> 'result'} assert_equal('result', La()) assert_equal([1, 3, 5], [1, 2, 3]->map({key, val -> key + val})) + + call CheckDefFailure(["filter([1, 2], {k,v -> 1})"], 'E1069:') enddef def Test_expr7_lambda_vim9script() diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim --- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -967,7 +967,7 @@ enddef def Line_continuation_in_lambda(): list let x = range(97, 100) - ->map({_,v -> nr2char(v) + ->map({_, v -> nr2char(v) ->toupper()}) ->reverse() return x diff --git a/src/userfunc.c b/src/userfunc.c --- a/src/userfunc.c +++ b/src/userfunc.c @@ -266,10 +266,20 @@ get_function_args( else if (any_default) { emsg(_("E989: Non-default argument follows default argument")); - mustend = TRUE; + goto err_ret; } if (*p == ',') + { ++p; + // Don't give this error when skipping, it makes the "->" not + // found in "{k,v -> x}" and give a confusing error. + if (!skip && in_vim9script() + && !IS_WHITE_OR_NUL(*p) && *p != endchar) + { + semsg(_(e_white_after), ","); + goto err_ret; + } + } else mustend = TRUE; } diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -755,6 +755,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1182, +/**/ 1181, /**/ 1180,