Skip to content

Commit b117205

Browse files
raflrgs
authored andcommitted
Improve mro merging error messages.
This makes them very similar to those produced by Algorithm::C3.
1 parent d21dfdd commit b117205

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

ext/mro/mro.xs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,23 @@ S_mro_get_linear_isa_c3(pTHX_ HV* stash, U32 level)
202202
/* If we had candidates, but nobody won, then the @ISA
203203
hierarchy is not C3-incompatible */
204204
if(!winner) {
205+
SV *errmsg;
206+
I32 i;
207+
208+
errmsg = newSVpvf("Inconsistent hierarchy during C3 merge of class '%s':\n\t"
209+
"current merge results [\n", HEK_KEY(stashhek));
210+
for (i = 0; i <= av_len(retval); i++) {
211+
SV **elem = av_fetch(retval, i, 0);
212+
sv_catpvf(errmsg, "\t\t%"SVf",\n", SVfARG(*elem));
213+
}
214+
sv_catpvf(errmsg, "\t]\n\tmerging failed on '%"SVf"'", SVfARG(cand));
215+
205216
/* we have to do some cleanup before we croak */
206217

207218
SvREFCNT_dec(retval);
208219
Safefree(heads);
209220

210-
Perl_croak(aTHX_ "Inconsistent hierarchy during C3 merge of class '%s': "
211-
"merging failed on parent '%"SVf"'", HEK_KEY(stashhek), SVfARG(cand));
221+
Perl_croak(aTHX_ "%"SVf, SVfARG(errmsg));
212222
}
213223
}
214224
}

0 commit comments

Comments
 (0)