> On 19 Jan 2016, at 15:05, Peter Pentchev (via RT) > <perl6-bugs-follo...@perl.org> wrote: > > # New Ticket Created by Peter Pentchev > # Please include the string: [perl #127315] > # in the subject line of all future correspondence about this issue. > # <URL: https://rt.perl.org/Ticket/Display.html?id=127315 > > > > Hi, > > First of all, thanks a lot for everything you've all done so far and keep > doing! > > > Now, I'm the author of the Serialize::Naive module (and, yeah, I guess I > should rename the Serialize-Naive distribution to use "::" and not "-"), and > it has a documented inability to serialize and deserialize classes with > attributes declared with the @. or %. twigils. Of course, this can be worked > around by "has Array[Str] $.foo", but still it feels somewhat incomplete to > me :) > > I've attached a sample file that demonstrates the several ways I've tried to > do that; I'm somewhat baffled by the "expected Str but got Array[Str]" error > - it looks like something tries to interpret the hash element's value as a > sequence containing a single array, while it should interpret it as, well, an > array, and get the values from it... I think. > > A minimum viable problem in case you don't want to slog through all the > diagnostics and conditionals: > > perl6 -e 'use v6; use strict; class Foo { has Str @.bar; }; my $f1 = > Foo.new(bar => <a b c>); say $f1.perl; my %data = bar => <a b c>; my $f2 = > Foo.new(|%data); say $f2.perl;' > > Foo.new(bar => Array[Str].new("a", "b", "c")) > Type check failed in assignment to @!bar; expected Str but got List > in block <unit> at -e line 1 > > Both this one-liner and the attached file fail in the same way in 2015.12 and > in: > This is Rakudo version 2015.12-213-g770d109 built on MoarVM version > 2015.12-29-g8079ca5 > implementing Perl 6.c. > > Thanks in advance for any advice or assistance, and keep up the great > work!<class-assign.p6>
Looks like this is really the root cause of the issue: $ 6 'my %h = a => <a b c>; dd %h' Hash %h = {:a($("a", "b", "c"))} I think this should actually say: Hash %h = {:a(("a", "b", "c"))} Somehow the list is getting itemized when assigning to the hash. However, the problem does not seem to be in Map.STORE: $ 6 'my $h = Hash.new; $h.STORE(Pair.new("a",<a b c>)); dd $h' Hash $h = ${:a(("a", "b", "c"))} $ 6 'my $h = Hash.new; $h.STORE(("a",<a b c>)); dd $h' Hash $h = ${:a(("a", "b", "c"))} So it looks to me this itemizing is somehow happening in the codegen of assignment to a hash. Liz