@@ -7890,6 +7890,27 @@ PP(pp_argcheck)
78907890 return NORMAL ;
78917891}
78927892
7893+ /* Helper function for collecting up hash key names for a human-readable
7894+ * error message string
7895+ */
7896+ #define accumulate_error_names (n_errorsp , error_namesp , namepv , namelen ) S_accumulate_error_names(aTHX_ n_errorsp, error_namesp, namepv, namelen)
7897+ STATIC void
7898+ S_accumulate_error_names (pTHX_ size_t * n_errorsp , SV * * error_namesp , const char * namepv , STRLEN namelen )
7899+ {
7900+ size_t n_errors = ++ (* n_errorsp );
7901+
7902+ SV * error_names = (* error_namesp );
7903+ if (!error_names )
7904+ error_names = (* error_namesp ) = newSVpvs_flags ("" , SVs_TEMP );
7905+
7906+ if (n_errors <= 5 ) {
7907+ /* Only bother collecting up the first 5 */
7908+ if (n_errors > 1 )
7909+ sv_catpvs (error_names , ", " );
7910+ sv_catpvf (error_names , "'%" UTF8f "'" , UTF8fARG (true, namelen , namepv ));
7911+ }
7912+ }
7913+
78937914PP (pp_multiparam )
78947915{
78957916 struct op_multiparam_aux * aux = (struct op_multiparam_aux * )cUNOP_AUX -> op_aux ;
@@ -7983,6 +8004,9 @@ PP(pp_multiparam)
79838004 SvPADSTALE_on (PAD_SVl (named -> padix ));
79848005 }
79858006
8007+ size_t n_errors = 0 ;
8008+ SV * error_names = NULL ;
8009+
79868010 while (argc ) {
79878011 SV * * svp ;
79888012
@@ -8060,22 +8084,32 @@ PP(pp_multiparam)
80608084 hv_store_ent (hv , name , newSVsv (val ), 0 );
80618085 }
80628086 else {
8063- // TODO: Consider collecting up all the names of unrecognised
8064- // in one string
8065- croak_caller ("Unrecognized named parameter '%" UTF8f "' to subroutine '%" SVf "'" ,
8066- UTF8fARG (true, namelen , namepv ), S_find_runcv_name ());
8087+ accumulate_error_names (& n_errors , & error_names , namepv , namelen );
80678088 }
80688089 }
80698090
8091+ if (n_errors ) {
8092+ if (n_errors > 5 )
8093+ sv_catpvs (error_names , ", ..." );
8094+ /* diag_listed_as: Unrecognized named parameter '%s' to subroutine '%s' */
8095+ croak_caller ("Unrecognized named parameter%s %" SVf " to subroutine '%" SVf "'" ,
8096+ n_errors > 1 ? "s" : "" , SVfARG (error_names ), SVfARG (S_find_runcv_name ()));
8097+ }
8098+
80708099 for (size_t namedix = 0 ; namedix < n_named ; namedix ++ ) {
80718100 struct op_multiparam_named_aux * named = aux -> named + namedix ;
80728101 if (!named -> is_required || !SvPADSTALE (PAD_SVl (named -> padix )))
80738102 continue ;
80748103
8075- // TODO: Consider collecting up all the names of missing
8076- // parameters in one string
8077- croak_caller ("Missing required named parameter '%" UTF8f "' to subroutine '%" SVf "'" ,
8078- UTF8fARG (true, named -> namelen , named -> namepv ), S_find_runcv_name ());
8104+ accumulate_error_names (& n_errors , & error_names , named -> namepv , named -> namelen );
8105+ }
8106+
8107+ if (n_errors ) {
8108+ if (n_errors > 5 )
8109+ sv_catpvs (error_names , ", ..." );
8110+ /* diag_listed_as: Missing required named parameter '%s' to subroutine '%s' */
8111+ croak_caller ("Missing required named parameter%s %" SVf " to subroutine '%" SVf "'" ,
8112+ n_errors > 1 ? "s" : "" , SVfARG (error_names ), SVfARG (S_find_runcv_name ()));
80798113 }
80808114 }
80818115
0 commit comments