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

shaped array attribute cannot be initialized from previously defined attributes #6073

Open
p6rt opened this issue Feb 19, 2017 · 3 comments
Open
Labels
LTA Less Than Awesome; typically an error message that could be better

Comments

@p6rt
Copy link

p6rt commented Feb 19, 2017

Migrated from rt.perl.org#130817 (status was 'open')

Searchable as RT130817$

@p6rt
Copy link
Author

p6rt commented Feb 19, 2017

From neven@luetic.de

class rect {
  has $.x;
  has $.y;

  has @​.area[$!x;$!y];
}

my $rect = rect.new(x => 3, y => 5);

gives​:
Cannot look up attributes in a VMNull type object
  in block <unit> at t2.p6 line 6

perl6 --version
This is Rakudo version 2017.02-29-gb9332ae built on MoarVM version 2017.02
implementing Perl 6.c.

@p6rt
Copy link
Author

p6rt commented Feb 20, 2017

From @LLFourn

I expected this wouldn't work because the attribute definition is parsed at
compile time when $!x and $!y aren't known. The error is definitely LTA.

You can do what you want like this​:

class rect {
  has $.x;
  has $.y;

  has Array $.area .= new(​:shape($!x,$!y))
}

say rect.new(x => 3,y => 4).area.shape[1] #-> 4

$.area has to be a $ attribute because @​ will do array assignment which
will lose the shape of the RHS array (and we are not able to do := in the
default for attributes atm).

LL

On Mon, Feb 20, 2017 at 8​:19 AM Neven Luetic <perl6-bugs-followup@​perl.org>
wrote​:

# New Ticket Created by Neven Luetic
# Please include the string​: [perl #​130817]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=130817 >

class rect {
has $.x;
has $.y;

has @​.area[$!x;$!y];
}

my $rect = rect.new(x => 3, y => 5);

gives​:
Cannot look up attributes in a VMNull type object
in block <unit> at t2.p6 line 6

perl6 --version
This is Rakudo version 2017.02-29-gb9332ae built on MoarVM version 2017.02
implementing Perl 6.c.

@p6rt
Copy link
Author

p6rt commented Feb 20, 2017

The RT System itself - Status changed from 'new' to 'open'

@p6rt p6rt added the LTA Less Than Awesome; typically an error message that could be better label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LTA Less Than Awesome; typically an error message that could be better
Projects
None yet
Development

No branches or pull requests

1 participant