Skip Menu |

This queue is for tickets about the Const-Fast CPAN distribution.

Report information
The Basics
Id: 103262
Status: rejected
Priority: 0/
Queue: Const-Fast

People
Owner: Nobody in particular
Requestors: OSCHWALD [...] cpan.org
Cc:
AdminCc:

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



Subject: Doesn't prevent addition of string to SV
For instance, using "encode_json" from JSON::XS: const my $h => { num => 42 }; encode_json($h); # {"num":42}; $h->{num} eq 42; # to cause the string to be added encode_json($h); # {"num":"42"} That said, I don't know if this is easily fixable. Readonly seems to prevent the addition of the PV, but I think there is some black magic going on there.
On Wed Apr 01 23:17:04 2015, OSCHWALD wrote: Show quoted text
> For instance, using "encode_json" from JSON::XS: > > const my $h => { num => 42 }; > encode_json($h); # {"num":42}; > $h->{num} eq 42; # to cause the string to be added > encode_json($h); # {"num":"42"} > > That said, I don't know if this is easily fixable. Readonly seems to > prevent the addition of the PV, but I think there is some black magic > going on there.
The internal representation of a scalar is considered an implementation detail for these purposes. It's understandable that it leaks on in a JSON module, but that doesn't mean the guarantee of this module (that the value won't change) has been violated. I see no way of fixing this unless core changes how this works. Leon
On 2015-04-11 10:50:07, LEONT wrote: Show quoted text
> On Wed Apr 01 23:17:04 2015, OSCHWALD wrote:
> > For instance, using "encode_json" from JSON::XS: > > > > const my $h => { num => 42 }; > > encode_json($h); # {"num":42}; > > $h->{num} eq 42; # to cause the string to be added > > encode_json($h); # {"num":"42"} > > > > That said, I don't know if this is easily fixable. Readonly seems to > > prevent the addition of the PV, but I think there is some black magic > > going on there.
> > The internal representation of a scalar is considered an > implementation detail for these purposes. It's understandable that it > leaks on in a JSON module, but that doesn't mean the guarantee of this > module (that the value won't change) has been violated. I see no way > of fixing this unless core changes how this works.
But maybe it's worth a note in the documentation? And a pointer to Readonly, where this supposedly works?