Skip Menu |

This queue is for tickets about the Class-XSAccessor CPAN distribution.

Report information
The Basics
Id: 103296
Status: open
Priority: 0/
Queue: Class-XSAccessor

People
Owner: Nobody in particular
Requestors: ribasushi [...] leporine.io
Cc: ether [...] cpan.org
AdminCc:

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



Subject: Convoluted invocation of accessor leads to interpreter panic
perl -e ' use Class::XSAccessor accessors => { foo => "foo" }; my $obj = bless { foo => {} }; $obj->foo->{bar} ||= do { # in the actual code this is buried in a reset() method # which is several stackframes removed from the do{} # in question (boy was that "fun" to isolate $obj->foo({}); "barval"; } '
As a point of reference, this also causes Mouse to fall over. perl -e 'use Mouse; has foo => (is => "rw"); my $obj = __PACKAGE__->new(foo => {}); $obj->foo->{bar} ||= do { $obj->foo({}); "barval" }'
Actually perl itself does not DWIM[1] in this case either :( I guess time to review some of my ||=-using code: perl -e ' use warnings; use strict; use Data::Dumper; sub foo { @_ > 1 ? $_[0]->{foo} = $_[1] : $_[0]->{foo} } my $obj = bless { foo => { boo => "ya" } }; warn Dumper $obj; $obj->foo->{bar} ||= do { $obj->foo({}); "barval"; }; warn Dumper $obj; ' [1] While I completely understand what goes behind the scenes, it is still surprising from a higher level POV.