Mercurial > vim
changeset 25038:efdb9608cc11 v8.2.3056
patch 8.2.3056: Vim9: using default value in lambda gives confusing error
Commit: https://github.com/vim/vim/commit/14ded11fcad77ebf41032ec80a95d516ca9acb1c
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jun 26 19:25:49 2021 +0200
patch 8.2.3056: Vim9: using default value in lambda gives confusing error
Problem: Vim9: using default value in lambda gives confusing error.
Solution: Pass "default_args" on the first pass to get the arguments.
(closes #8455)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 26 Jun 2021 19:30:03 +0200 |
parents | 811921061790 |
children | 54c7c9690eaa |
files | src/testdir/test_vim9_func.vim src/userfunc.c src/version.c |
diffstat | 3 files changed, 9 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -918,6 +918,12 @@ def Test_call_lambda_args() CheckScriptFailure(['vim9script'] + lines, 'E1168:') lines =<< trim END + var Ref: func(any, ?any): bool + Ref = (_, y = 1) => false + END + CheckDefAndScriptFailure(lines, 'E1172:') + + lines =<< trim END def ShadowLocal() var one = 1 var l = [1, 2, 3]
--- a/src/userfunc.c +++ b/src/userfunc.c @@ -1222,7 +1222,7 @@ get_lambda_tv( s = *arg + 1; ret = get_function_args(&s, equal_arrow ? ')' : '-', NULL, types_optional ? &argtypes : NULL, types_optional, evalarg, - NULL, NULL, TRUE, NULL, NULL); + NULL, &default_args, TRUE, NULL, NULL); if (ret == FAIL || skip_arrow(s, equal_arrow, &ret_type, NULL) == NULL) { if (types_optional)