@@ -534,8 +534,16 @@ typval2type(typval_T *tv, garray_T *type_gap)
534534 if (name != NULL )
535535 // TODO: how about a builtin function?
536536 ufunc = find_func (name , FALSE, NULL );
537- if (ufunc != NULL && ufunc -> uf_func_type != NULL )
538- return ufunc -> uf_func_type ;
537+ if (ufunc != NULL )
538+ {
539+ // May need to get the argument types from default values by
540+ // compiling the function.
541+ if (ufunc -> uf_def_status == UF_TO_BE_COMPILED
542+ && compile_def_function (ufunc , TRUE, NULL ) == FAIL )
543+ return NULL ;
544+ if (ufunc -> uf_func_type != NULL )
545+ return ufunc -> uf_func_type ;
546+ }
539547 }
540548
541549 actual = alloc_type (type_gap );
@@ -1916,20 +1924,23 @@ free_locals(cctx_T *cctx)
19161924
19171925/*
19181926 * Skip over a type definition and return a pointer to just after it.
1927+ * When "optional" is TRUE then a leading "?" is accepted.
19191928 */
19201929 char_u *
1921- skip_type (char_u * start )
1930+ skip_type (char_u * start , int optional )
19221931{
19231932 char_u * p = start ;
19241933
1934+ if (optional && * p == '?' )
1935+ ++ p ;
19251936 while (ASCII_ISALNUM (* p ) || * p == '_' )
19261937 ++ p ;
19271938
19281939 // Skip over "<type>"; this is permissive about white space.
19291940 if (* skipwhite (p ) == '<' )
19301941 {
19311942 p = skipwhite (p );
1932- p = skip_type (skipwhite (p + 1 ));
1943+ p = skip_type (skipwhite (p + 1 ), FALSE );
19331944 p = skipwhite (p );
19341945 if (* p == '>' )
19351946 ++ p ;
@@ -1945,7 +1956,7 @@ skip_type(char_u *start)
19451956 {
19461957 char_u * sp = p ;
19471958
1948- p = skip_type (p );
1959+ p = skip_type (p , TRUE );
19491960 if (p == sp )
19501961 return p ; // syntax error
19511962 if (* p == ',' )
@@ -1954,15 +1965,15 @@ skip_type(char_u *start)
19541965 if (* p == ')' )
19551966 {
19561967 if (p [1 ] == ':' )
1957- p = skip_type (skipwhite (p + 2 ));
1968+ p = skip_type (skipwhite (p + 2 ), FALSE );
19581969 else
19591970 ++ p ;
19601971 }
19611972 }
19621973 else
19631974 {
19641975 // handle func: return_type
1965- p = skip_type (skipwhite (p + 1 ));
1976+ p = skip_type (skipwhite (p + 1 ), FALSE );
19661977 }
19671978 }
19681979
0 commit comments