Skip Menu |

This queue is for tickets about the Syntax-Keyword-Dynamically CPAN distribution.

Report information
The Basics
Id: 131738
Status: resolved
Priority: 0/
Queue: Syntax-Keyword-Dynamically

People
Owner: Nobody in particular
Requestors: leonerd-cpan [...] leonerd.org.uk
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.01
Fixed in: 0.02



Subject: dynamically $href->{newkey} doesn't delete on restore
$ perl -Mblib -MSyntax::Keyword::Dynamically -MData::Dump=pp -E ' my $href; { dynamically $href->{newkey} = "value" } say pp($href); ' { newkey => undef } Expected output {} -- Paul Evans
Initial thoughts on this are that it's nontrivial. The current implementation simply adjusts the optree of an OP_SASSIGN to insert the internal custom op called pp_startdyn just after the LHS has been fetched as an SV, before it is assigned to. That simply saves the value, allowing it to be restored later. But by this time we've forgotten if it was an element of a hash and if so whether the element existed before we started. In perl core's case of `local $hash{key} = ...` the local'isation part is performed by pp_helem itself in the presence of the OPpLVAL_INTRO flag so it can do something special. A fix for this issue would have to take place at or around the time of the pp_helem op that forms the LHS of the assignment so it can know of the presence or absence of the key beforehand. -- Paul Evans
Another awkward case is my $h; { dynamically $h->{key} = "val"; delete $h->{key} } afterwards we have to put the key back in, because the SV itself has been removed in the meantime -- Paul Evans
An attempt at solving this one. -- Paul Evans
Subject: rt131738.patch

Message body is not shown because it is too large.

This was mostly added in 0.02, give or take some cornercases, e.g. RT132545 which is now being fixed too. -- Paul Evans