Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken default value assignment on shaped array attributes #1226

Open
kalkin opened this issue Nov 2, 2017 · 4 comments

Comments

Projects
None yet
4 participants
@kalkin
Copy link
Contributor

commented Nov 2, 2017

The Problem

class F { 
    has @.color[4] = <1 2 3 4>;
}; 
my $f = F.new();
say $f.color

Expected Behavior

$f.color == <1 2 3 4>

Actual Behavior

$f.color == [(Any) (Any) (Any) (Any)]

Environment

Seems to happen in 2017.09 and HEAD version used by the m bot in #perl6

@TisonKun

This comment has been minimized.

Copy link
Contributor

commented Nov 2, 2017

➜  perl6 -e 'class F { has @.color = <1 2 3 4>; }; my $f = F.new(); say $f.color'
[1 2 3 4]
➜  perl6 -v
This is Rakudo version 2017.10-64-g697e4ecff built on MoarVM version 2017.10-29-g116c7a13
implementing Perl 6.c.
➜  perl6 -e 'class F { has @.color = <1 2 3 4>; }; my $f = F.new(); dd $f.color' 
Array @!color = [IntStr.new(1, "1"), IntStr.new(2, "2"), IntStr.new(3, "3"), IntStr.new(4, "4")]

Above work well, but

➜  perl6 -e 'class A { has @.a[4] = <a b c d e> }; dd A.new.a'
Array.new(:shape(4,), [Any, Any, Any, Any])
➜  perl6 -e 'class F { has @.color[4] = <1 2 3 4> }; my $f = F.new(); say $f.color;'
[(Any) (Any) (Any) (Any)]

these are broken, where the former should die and the latter did not init well

@kalkin

This comment has been minimized.

Copy link
Contributor Author

commented Nov 2, 2017

Sorry I meant has @.color[4] = <1 2 3 4>; Will edit the issue

@lizmat

This comment has been minimized.

Copy link
Contributor

commented Nov 2, 2017

lizmat added a commit that referenced this issue Nov 2, 2017

Temporary fix for GH #1226
- throw an X::Comp::NYI for buildplan code 9 with a 4,5,6,7
- show a work around

Can't help but wonder that if we recommend this workaround, why not
automatically generate that code then?  This could be done by adding
another code block like TWEAK to the BUILDPLAN, with the correct
code pre-generated.
@lizmat

This comment has been minimized.

Copy link
Contributor

commented Nov 2, 2017

lizmat added a commit that referenced this issue Nov 2, 2017

lizmat added a commit that referenced this issue Nov 15, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.