Skip to content

Commit d594884

Browse files
author
Zefram
committed
better comments about Carp overload logic
The comments originally added by commit c99363a for [perl #132828] were unclear and a bit over-excited.
1 parent d0d5e94 commit d594884

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

dist/Carp/lib/Carp.pm

+9-10
Original file line numberDiff line numberDiff line change
@@ -336,17 +336,16 @@ sub format_arg {
336336
}
337337
else
338338
{
339-
# this particular bit of magic looking code is responsible for disabling overloads
340-
# while we are stringifing arguments, otherwise if an overload calls a Carp sub we
341-
# could end up in infinite recursion, which means we will exhaust the C stack and
342-
# then segfault. Calling Carp obviously should not trigger an untrappable exception
343-
# from Carp itself! - Yves
344339
if ($pack->can("((")) {
345-
# this eval is required, or fail the overload test
346-
# in dist/Carp/t/vivify_stash.t, which is really quite weird.
347-
# Even if we never enter this block, the presence of the require
348-
# causes the test to fail. This seems like it might be a bug
349-
# in require. Needs further investigation - Yves
340+
# Argument is blessed into a class with overloading, and
341+
# so might have an overloaded stringification. We don't
342+
# want to risk getting the overloaded stringification,
343+
# so we need to use overload::StrVal() below. But it's
344+
# possible that the overload module hasn't been loaded:
345+
# overload methods can be installed without it. So load
346+
# the module here. The eval layer here avoids the
347+
# compile-time effect of require vivifying the target
348+
# module's stash.
350349
eval "require overload; 1"
351350
or return "use overload failed";
352351
}

0 commit comments

Comments
 (0)