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

Attributes doesn't get default values when BUILD-method exists #1223

Closed
p6rt opened this issue Aug 13, 2009 · 8 comments
Closed

Attributes doesn't get default values when BUILD-method exists #1223

p6rt opened this issue Aug 13, 2009 · 8 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Aug 13, 2009

Migrated from rt.perl.org#68498 (status was 'resolved')

Searchable as RT68498$

@p6rt
Copy link
Author

p6rt commented Jun 20, 2009

From johan.viklund@gmail.com

class T {
  has $.thing = 'default';
  submethod BUILD {}
}

say T.new.thing; # Use of uninitialized value

When BUILD is removed it works.

--
Johan Viklund

@p6rt
Copy link
Author

p6rt commented Aug 13, 2009

From wolf.arthur@gmail.com

hello
first bug report so i'm not sure i'm doing this right.

so, perl6 -e ' class A { has $.a; }; my $a = A.new( a => 2 ); say $a.a '
this outputs 2 as expected

but :
perl6 -e ' class A { has $.a; submethod BUILD { say "OH HAI" } }; my $a =
A.new( a => 2 ); say $a.a '
outputs :
OH HAI
Use of uninitialized value

where it should output :
OH HAI
2

( I think )

Thanks a lot !
( is there some way I can follow / be warned on the resolution of this bug ?
)

--
Courage (et Bonne humeur|and Good humor)\.

@p6rt
Copy link
Author

p6rt commented Aug 19, 2009

From @jnthn

Merging these two duplicate tickets.

@p6rt
Copy link
Author

p6rt commented Jul 12, 2010

From @bbkr

On Kiev build​:

$ perl6 -e ' class A { has $.a; method BUILD { say "OH HAI" } }; my $a =
A.new( a => 2 ); say $a.a '
OH HAI
Any()

@p6rt
Copy link
Author

p6rt commented Jul 12, 2010

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

@p6rt
Copy link
Author

p6rt commented Jul 21, 2010

From @markjreed

rakudo​: class Foo { has $.bar = "baz"; }; say Foo.new.bar
<p6eval> rakudo 278366​: OUTPUT <baz>

rakudo​: class Foo { has $.bar = "baz"; submethod BUILD{}}; say Foo.new.bar
<p6eval> rakudo 278366​: OUTPUT <Any()>

Per S12​:
  Whether you write your own BUILD or not, at the end of the BUILD,
any default attribute values are implicitly copied into any attributes
that haven't otherwise been initialized.

--
Mark J. Reed <markjreed@​gmail.com>

@p6rt
Copy link
Author

p6rt commented Oct 1, 2011

From @moritz

Seems to be fixed now. A basic passing test is in
t/spec/S12-attributes/instance.t.

@p6rt
Copy link
Author

p6rt commented Oct 1, 2011

@moritz - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Oct 1, 2011
@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant