This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
sv.c/find_uninit_var: Explain kid-scanning loop better
authorFather Chrysostomos <sprout@cpan.org>
Wed, 30 Nov 2011 02:04:35 +0000 (18:04 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Wed, 30 Nov 2011 02:04:35 +0000 (18:04 -0800)
Hopefully this explanation will be clearer and will prevent clumsy
individuals like me from introducing bugs like #103766.

sv.c

diff --git a/sv.c b/sv.c
index f1fe1f2..70a912c 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -14265,8 +14265,13 @@ S_find_uninit_var(pTHX_ const OP *const obase, const SV *const uninit_sv,
        if (!o)
            break;
 
-       /* if all except one arg are constant, or have no side-effects,
-        * or are optimized away, then it's unambiguous */
+       /* This loop checks all the kid ops, skipping any that cannot pos-
+        * sibly be responsible for the uninitialized value; i.e., defined
+        * constants and ops that return nothing.  If there is only one op
+        * left that is not skipped, then we *know* it is responsible for
+        * the uninitialized value.  If there is more than one op left, we
+        * have to look for an exact match in the while() loop below.
+        */
        o2 = NULL;
        for (kid=o; kid; kid = kid->op_sibling) {
            if (kid) {