comparison src/userfunc.c @ 19912:d4fa9db88d16 v8.2.0512

patch 8.2.0512: Vim9: no optional arguments in func type Commit: https://github.com/vim/vim/commit/5deeb3f1f9db4eabd36e99cbf857fe376eb37e10 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Apr 5 17:08:17 2020 +0200 patch 8.2.0512: Vim9: no optional arguments in func type Problem: Vim9: no optional arguments in func type. Solution: Check for question mark after type. Find function reference without function().
author Bram Moolenaar <Bram@vim.org>
date Sun, 05 Apr 2020 17:15:25 +0200
parents ff89394116ea
children 3ff714d765ba
comparison
equal deleted inserted replaced
19911:70edfdef3b83 19912:d4fa9db88d16
949 ga_clear_strings(&(fp->uf_lines)); 949 ga_clear_strings(&(fp->uf_lines));
950 VIM_CLEAR(fp->uf_name_exp); 950 VIM_CLEAR(fp->uf_name_exp);
951 VIM_CLEAR(fp->uf_arg_types); 951 VIM_CLEAR(fp->uf_arg_types);
952 VIM_CLEAR(fp->uf_def_arg_idx); 952 VIM_CLEAR(fp->uf_def_arg_idx);
953 VIM_CLEAR(fp->uf_va_name); 953 VIM_CLEAR(fp->uf_va_name);
954 while (fp->uf_type_list.ga_len > 0)
955 vim_free(((type_T **)fp->uf_type_list.ga_data)
956 [--fp->uf_type_list.ga_len]);
954 ga_clear(&fp->uf_type_list); 957 ga_clear(&fp->uf_type_list);
955 #ifdef FEAT_PROFILE 958 #ifdef FEAT_PROFILE
956 VIM_CLEAR(fp->uf_tml_count); 959 VIM_CLEAR(fp->uf_tml_count);
957 VIM_CLEAR(fp->uf_tml_total); 960 VIM_CLEAR(fp->uf_tml_total);
958 VIM_CLEAR(fp->uf_tml_self); 961 VIM_CLEAR(fp->uf_tml_self);
3011 fp->uf_refcount = 1; 3014 fp->uf_refcount = 1;
3012 } 3015 }
3013 fp->uf_args = newargs; 3016 fp->uf_args = newargs;
3014 fp->uf_def_args = default_args; 3017 fp->uf_def_args = default_args;
3015 fp->uf_ret_type = &t_any; 3018 fp->uf_ret_type = &t_any;
3019 fp->uf_func_type = &t_func_any;
3016 3020
3017 if (eap->cmdidx == CMD_def) 3021 if (eap->cmdidx == CMD_def)
3018 { 3022 {
3019 int lnum_save = SOURCING_LNUM; 3023 int lnum_save = SOURCING_LNUM;
3020 3024
3021 // error messages are for the first function line 3025 // error messages are for the first function line
3022 SOURCING_LNUM = sourcing_lnum_top; 3026 SOURCING_LNUM = sourcing_lnum_top;
3023 3027
3024 // parse the argument types 3028 // parse the argument types
3025 ga_init2(&fp->uf_type_list, sizeof(type_T), 5); 3029 ga_init2(&fp->uf_type_list, sizeof(type_T *), 10);
3026 3030
3027 if (argtypes.ga_len > 0) 3031 if (argtypes.ga_len > 0)
3028 { 3032 {
3029 // When "varargs" is set the last name/type goes into uf_va_name 3033 // When "varargs" is set the last name/type goes into uf_va_name
3030 // and uf_va_type. 3034 // and uf_va_type.