Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Mouse CPAN distribution.

Report information
The Basics
Id: 82945
Status: resolved
Priority: 0/
Queue: Mouse

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

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



Subject: Mutating references to the return values of getters mutates the contents of the hash
Consider the output of perl -e 'package Foo; use Mouse; has bar => (is => "ro"); my $o = bless {bar => 1}; warn ${\$o->bar}++ for 1..5' (outputs 1 through 5) vs perl -e 'package Foo; use Moose; has bar => (is => "ro"); my $o = bless {bar => 1}; warn ${\$o->bar}++ for 1..5' (outputs 1, 5 times) What's worse Mouse is inconsistent with itself: MOUSE_PUREPERL=1 perl -e 'package Foo; use Mouse; has bar => (is => "ro"); my $o = bless {bar => 1}; warn ${\$o->bar}++ for 1..5' (outputs 1, 5 times)
Thanks. It is interesting but because of performance reasons, I won't change this behavior.
Reopening this as a request for documentation. If this bug isn't going to be fixed, it should at least be listed in Mouse::XS as caveat of using the XS version of Mouse.
Added a caveat: https://github.com/gfx/p5-Mouse/commit/0d9c49c38aa3385abfd641a1477373730fad75cd -- Goro Fuji (gfx) GFUJI at CPAN.org