develooper Front page | perl.perl5.porters | Postings from June 2019

[perl #134193] Accessing @{^CAPTURE} before %{^CAPTURE} empties thelatter

Thread Previous
From:
Tony Cook via RT
Date:
June 17, 2019 01:53
Subject:
[perl #134193] Accessing @{^CAPTURE} before %{^CAPTURE} empties thelatter
Message ID:
rt-4.0.24-26375-1560736361-127.134193-15-0@perl.org
On Thu, 13 Jun 2019 03:46:27 -0700, hv wrote:
> On Wed, 12 Jun 2019 17:22:33 -0700, tonyc wrote:
> > The attached fixes it (applies on top of the 131867 fix).
> 
> Can you explain why the similar code for *+ and *- is not similarly
> wrong? That might be worth a comment in the code too: it looks like
> this bug started as essentially a copy of that code.

There's special handling in gv_fetchpvn_flags():

	    if (len == 1 && stash == PL_defstash) {
                maybe_multimagic_gv(gv, name, sv_type);
	    }

that calls maybe_multimagic_gv() even if the glob already exists for single character names.

Loading Tie::Hash::NamedCapture when only @{^CAPTURE} is being referenced is a minor performance hit, maybe that's what the handling for @+ is trying to avoid.

> It would also be worth swapping the '+' and '-' arguments in the two
> require_tie_mod_s() calls, as Hauke also noted - if anyone ever sees
> it, it'll be a confusing-enough error message without being confusing
> for the wrong reason.

Attached, applies after the other two.

Tony


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=134193

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About