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
Download (untitled) / with headers
text/plain 332b
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"; } '
Download (untitled) / with headers
text/plain 199b
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" }'
Download (untitled) / with headers
text/plain 550b
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.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.