Skip Menu |

This queue is for tickets about the Data-Dump-Streamer CPAN distribution.

Report information
The Basics
Id: 103543
Status: rejected
Priority: 0/
Queue: Data-Dump-Streamer

People
Owner: Nobody in particular
Requestors: mjgardner [...] cpan.org
Cc: Mark [...] Overmeer.net
AdminCc:

Bug Information
Severity: (no value)
Broken in: 2.38
Fixed in: (no value)



CC: Mark [...] Overmeer.net
Subject: Syntax error generated when delete and || used in an anonymous hash inside coderefs
I'm trying to use DDS in combination with XML::Compile::SOAP and ran into a bug when DDS is outputting its coderefs. I've reduced it down to the attached test case, where the "broken" sub represents code that is serialized into a syntax error, and the "fixed" sub is not. The only difference is that "fixed" adds an empty list () into the empty hashref {}.
Subject: testcase.pl
#!/usr/bin/env perl use strict; use warnings; use Data::Dump::Streamer; for (qw(broken fixed)) { print "running $_\n"; no strict 'refs'; Dump(&$_); print "evaling $_\n"; eval_dump( \&$_ ); } sub eval_dump { my $code_ref = shift; no strict 'vars'; if ( eval Dump($code_ref)->Out() ) { Dump($code_ref) } else { print "$@\n"; Dump($code_ref) } } sub broken { my %test = ( foo => { bar => 1 } ); %{ delete $test{foo} || {} }; } sub fixed { my %test = ( foo => { bar => 1 } ); %{ delete $test{foo} || { () } }; }
Subject: Re: [rt.cpan.org #103543] Syntax error generated when delete and || used in an anonymous hash inside coderefs
Date: Sat, 18 Apr 2015 01:00:56 +0200
To: Mark Gardner via RT <bug-Data-Dump-Streamer [...] rt.cpan.org>
From: Mark Overmeer <mark [...] overmeer.net>
* Mark Gardner via RT (bug-Data-Dump-Streamer@rt.cpan.org) [150414 16:58]: Show quoted text
> %{ delete $test{foo} || {} }; > %{ delete $test{foo} || { () } };
The dumped versions produce %{ {} unless delete $test{foo} }; resp %{ {()} unless delete $test{foo} }; The first cannot be parsed by perl. Simpler examples: perl -we '$x = %{{}}' Unmatched right curly bracket at -e line 1, at end of line syntax error at -e line 1, near "%{{}}" Execution of -e aborted due to compilation errors. perl -we '$x = %{{()}}' Name "main::x" used only once: possible typo at -e line 1. perl -we '$x = %{+{}}' Name "main::x" used only once: possible typo at -e line 1. The error message in the first case is incorrect. I expect that Perl takes the wrong interpretation for '{}', which should produce a different message. -- MarkOv ------------------------------------------------------------------------ Mark Overmeer MSc MARKOV Solutions Mark@Overmeer.net solutions@overmeer.net http://Mark.Overmeer.net http://solutions.overmeer.net
RT-Send-CC: Mark [...] Overmeer.net
On Fri Apr 17 19:01:16 2015, Mark@Overmeer.net wrote: Show quoted text
> * Mark Gardner via RT (bug-Data-Dump-Streamer@rt.cpan.org) [150414 16:58]:
> > %{ delete $test{foo} || {} }; > > %{ delete $test{foo} || { () } };
> > The dumped versions produce > %{ {} unless delete $test{foo} }; > resp %{ {()} unless delete $test{foo} }; > > The first cannot be parsed by perl. > Simpler examples: > > perl -we '$x = %{{}}' > Unmatched right curly bracket at -e line 1, at end of line > syntax error at -e line 1, near "%{{}}" > Execution of -e aborted due to compilation errors. > > perl -we '$x = %{{()}}' > Name "main::x" used only once: possible typo at -e line 1. > > perl -we '$x = %{+{}}' > Name "main::x" used only once: possible typo at -e line 1. > > The error message in the first case is incorrect. I expect that > Perl takes the wrong interpretation for '{}', which should produce > a different message.
Sorry for the delay in replying to this ticket. This is actually a bug in B::Deparse, which DDS uses for code refs. $ perl -MO=Deparse -e'$x=sub{ %{ delete $_{x} || {} } };' $x = sub { %{{} unless delete $_{'x'};}; } ; -e syntax OK I am going to reject this ticket. it needs to be filed with the perl5porters as a bug in perl.
RT-Send-CC: Mark [...] Overmeer.net
On Thu Dec 24 22:35:42 2015, YVES wrote: Show quoted text
> This is actually a bug in B::Deparse, which DDS uses for code refs. > > $ perl -MO=Deparse -e'$x=sub{ %{ delete $_{x} || {} } };' > $x = sub { > %{{} unless delete $_{'x'};}; > } > ; > -e syntax OK > > I am going to reject this ticket. it needs to be filed with the > perl5porters as a bug in perl.
I noted the thread in RT#127026 you filed for B::Deparse, though. The message in https://rt.perl.org/Public/Bug/Display.html?id=127026#txn-1381679 sounds like you might consider a workaround in DDS. Either way, I appreciate the investigation and work involved. Thanks.