Subject: | blessedness lost from unreferenced scalars |
Date: | Mon, 2 Feb 2015 14:33:02 +0000 |
To: | bug-Sereal-Encoder [...] rt.cpan.org |
From: | Zefram <zefram [...] fysh.org> |
$ perl -MSereal::Encoder=encode_sereal -MSereal::Decoder=decode_sereal -MData::Dumper=Dumper -we '@a=(3); bless \$a[0], "Foo"; print Dumper \$a[0]; print Dumper \decode_sereal(encode_sereal(\@a))->[0]'
$VAR1 = bless( do{\(my $o = 3)}, 'Foo' );
$VAR1 = \3;
$a[0] is blessed, but the serialisation of @a didn't preserve the
blessedness. I suspect that underneath this there's some confusion
about how blessing works: although blessing is always performed through
a reference, and blessed objects are always handled through references,
the status of being blessed is a property of the referenced object,
not of the reference itself.
I don't have any real code that's misbehaving due to this. It's an
artificial test case that I came up with after reading the Sereal
format spec.
-zefram