Mercurial > vim
diff src/evalfunc.c @ 25449:5dce28f92d04 v8.2.3261
patch 8.2.3261: Vim9: when compiling repeat(123, N) return type is number
Commit: https://github.com/vim/vim/commit/1780f08ba42837b6d4a5f0451117a79b2d49974a
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jul 31 22:03:59 2021 +0200
patch 8.2.3261: Vim9: when compiling repeat(123, N) return type is number
Problem: Vim9: when compiling repeat(123, N) return type is number.
Solution: Make return type a string. (closes https://github.com/vim/vim/issues/8664)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 31 Jul 2021 22:15:02 +0200 |
parents | 634aed775408 |
children | b8a6a0007dc3 |
line wrap: on
line diff
--- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -931,6 +931,13 @@ ret_first_arg(int argcount, type_T **arg return argtypes[0]; return &t_void; } + static type_T * +ret_repeat(int argcount UNUSED, type_T **argtypes) +{ + if (argtypes[0] == &t_number) + return &t_string; + return argtypes[0]; +} // for map(): returns first argument but item type may differ static type_T * ret_first_cont(int argcount UNUSED, type_T **argtypes) @@ -1813,7 +1820,7 @@ static funcentry_T global_functions[] = {"rename", 2, 2, FEARG_1, arg2_string, ret_number_bool, f_rename}, {"repeat", 2, 2, FEARG_1, arg2_repeat, - ret_first_arg, f_repeat}, + ret_repeat, f_repeat}, {"resolve", 1, 1, FEARG_1, arg1_string, ret_string, f_resolve}, {"reverse", 1, 1, FEARG_1, arg1_list_or_blob,