@@ -294,9 +294,10 @@ check_defined(char_u *p, size_t len, cctx_T *cctx)
294294 if (lookup_script (p , len ) == OK
295295 || (cctx != NULL
296296 && (lookup_local (p , len , cctx ) != NULL
297- || find_imported (p , len , cctx ) != NULL )))
297+ || lookup_arg (p , len , NULL , NULL , NULL , cctx ) == OK ))
298+ || find_imported (p , len , cctx ) != NULL )
298299 {
299- semsg ("E1073: imported name already defined: %s" , p );
300+ semsg (_ ( e_already_defined ) , p );
300301 return FAIL ;
301302 }
302303 return OK ;
@@ -4899,17 +4900,21 @@ compile_nested_function(exarg_T *eap, cctx_T *cctx)
48994900 int is_global = * eap -> arg == 'g' && eap -> arg [1 ] == ':' ;
49004901 char_u * name_start = eap -> arg ;
49014902 char_u * name_end = to_name_end (eap -> arg , is_global );
4902- char_u * name = get_lambda_name () ;
4903+ char_u * lambda_name ;
49034904 lvar_T * lvar ;
49044905 ufunc_T * ufunc ;
49054906 int r ;
49064907
4908+ if (check_defined (name_start , name_end - name_start , cctx ) == FAIL )
4909+ return NULL ;
4910+
49074911 eap -> arg = name_end ;
49084912 eap -> getline = exarg_getline ;
49094913 eap -> cookie = cctx ;
49104914 eap -> skip = cctx -> ctx_skip == SKIP_YES ;
49114915 eap -> forceit = FALSE;
4912- ufunc = def_function (eap , name );
4916+ lambda_name = get_lambda_name ();
4917+ ufunc = def_function (eap , lambda_name );
49134918
49144919 if (ufunc == NULL )
49154920 return NULL ;
@@ -4925,13 +4930,15 @@ compile_nested_function(exarg_T *eap, cctx_T *cctx)
49254930 if (func_name == NULL )
49264931 r = FAIL ;
49274932 else
4928- r = generate_NEWFUNC (cctx , name , func_name );
4933+ r = generate_NEWFUNC (cctx , lambda_name , func_name );
49294934 }
49304935 else
49314936 {
49324937 // Define a local variable for the function reference.
49334938 lvar = reserve_local (cctx , name_start , name_end - name_start ,
49344939 TRUE, ufunc -> uf_func_type );
4940+ if (lvar == NULL )
4941+ return NULL ;
49354942 if (generate_FUNCREF (cctx , ufunc -> uf_dfunc_idx ) == FAIL )
49364943 return NULL ;
49374944 r = generate_STORE (cctx , ISN_STORE , lvar -> lv_idx , NULL );
0 commit comments