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} || { () } };
}