comparison src/vim9execute.c @ 23350:9b86957ddd95 v8.2.2218

patch 8.2.2218: Vim9: failure if passing more args to lambda than expected Commit: https://github.com/vim/vim/commit/fc0e8f5c3ef51c86cfa4a51f92b264ef79962b9d Author: Bram Moolenaar <Bram@vim.org> Date: Fri Dec 25 20:24:51 2020 +0100 patch 8.2.2218: Vim9: failure if passing more args to lambda than expected Problem: Vim9: failure if passing more arguments to a lambda than expected. Solution: Only put expected arguments on the stack. (closes https://github.com/vim/vim/issues/7548)
author Bram Moolenaar <Bram@vim.org>
date Fri, 25 Dec 2020 20:30:03 +0100
parents 456d625bb8c1
children f181fe2150ab
comparison
equal deleted inserted replaced
23349:1d0b46988d16 23350:9b86957ddd95
1018 return FAIL; 1018 return FAIL;
1019 } 1019 }
1020 ga_init2(&ectx.ec_trystack, sizeof(trycmd_T), 10); 1020 ga_init2(&ectx.ec_trystack, sizeof(trycmd_T), 10);
1021 ga_init2(&ectx.ec_funcrefs, sizeof(partial_T *), 10); 1021 ga_init2(&ectx.ec_funcrefs, sizeof(partial_T *), 10);
1022 1022
1023 // Put arguments on the stack. 1023 // Put arguments on the stack, but no more than what the function expects.
1024 for (idx = 0; idx < argc; ++idx) 1024 // A lambda can be called with more arguments than it uses.
1025 for (idx = 0; idx < argc
1026 && (ufunc->uf_va_name != NULL || idx < ufunc->uf_args.ga_len);
1027 ++idx)
1025 { 1028 {
1026 if (ufunc->uf_arg_types != NULL && idx < ufunc->uf_args.ga_len 1029 if (ufunc->uf_arg_types != NULL && idx < ufunc->uf_args.ga_len
1027 && check_typval_type(ufunc->uf_arg_types[idx], &argv[idx], 1030 && check_typval_type(ufunc->uf_arg_types[idx], &argv[idx],
1028 idx + 1) == FAIL) 1031 idx + 1) == FAIL)
1029 goto failed_early; 1032 goto failed_early;