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

weird error when accessing an attribute from a "where" of another attribute #6062

Closed
p6rt opened this issue Feb 9, 2017 · 5 comments
Closed
Labels

Comments

@p6rt
Copy link

p6rt commented Feb 9, 2017

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

Searchable as RT130748$

@p6rt
Copy link
Author

p6rt commented Feb 9, 2017

From @FCO

I’m getting a "VMNull type object” error when I try to access an attribute from the “where” of another attribute.

https://irclog.perlgeek.de/perl6/2017-02-09#i_14068796

<SmokeMachine> Fernando Corrêa de Oliveira m​: class C { has Int $.a = 42; has Str $.b where $!a }; say C.new <http://c.new/>&#8203;: :b<42> # should it die with this error?
22​:32 C<•camelia> rakudo-moar f85978​: OUTPUT«Cannot look up attributes in a VMNull type object␤ in block <unit> at <tmp> line 1␤␤»
22​:32 S<SmokeMachine> Fernando Corrêa de Oliveira m​: class C { has Int $.a = 42; has Str $.b where $!a }; say C.new <http://c.new/>&#8203;: :42b
22​:32 C<•camelia> rakudo-moar f85978​: OUTPUT«Type check failed in assignment to $!b; expected <anon> but got Int (42)␤ in block <unit> at <tmp> line 1␤␤»
22​:33 S<SmokeMachine> Fernando Corrêa de Oliveira m​: class C { has Int $.a = 42; has Str $.b where $!a }; say C.new.a
22​:33 C<•camelia> rakudo-moar f85978​: OUTPUT«42␤»
22​:33 → pierrot joined ↔ pyrimidine popped in ↔ Ven nipped out
22​:47 S<SmokeMachine> Fernando Corrêa de Oliveira m​: class C { has Int $.a = 42; has Str $.b where $!a }; say C.new <http://c.new/>&#8203;: :42a :42b
22​:47 C<•camelia> rakudo-moar f85978​: OUTPUT«Type check failed in assignment to $!b; expected <anon> but got Int (42)␤ in block <unit> at <tmp> line 1␤␤»
22​:47 S<SmokeMachine> Fernando Corrêa de Oliveira m​: class C { has Int $.a = 42; has Int $.b where $!a }; say C.new <http://c.new/>&#8203;: :42a :42b
22​:47 C<•camelia> rakudo-moar f85978​: OUTPUT«Cannot look up attributes in a VMNull type object␤ in block <unit> at <tmp> line 1␤␤»

@p6rt
Copy link
Author

p6rt commented Feb 9, 2018

From @zoffixznet

On Wed, 08 Feb 2017 17​:04​:56 -0800, fernandocorrea@​gmail.com wrote​:

I’m getting a "VMNull type object” error when I try to access an
attribute from the “where” of another attribute.

https://irclog.perlgeek.de/perl6/2017-02-09#i_14068796

<SmokeMachine> Fernando Corrêa de Oliveira m​: class C { has Int $.a =
42; has Str $.b where $!a }; say C.new <http://c.new/>&#8203;: :b<42> #
should it die with this error?
22​:32 C<•camelia> rakudo-moar f85978​: OUTPUT«Cannot look up attributes
in a VMNull type object␤ in block <unit> at <tmp> line 1␤␤»
22​:32 S<SmokeMachine> Fernando Corrêa de Oliveira m​: class C { has Int
$.a = 42; has Str $.b where $!a }; say C.new <http://c.new/>&#8203;: :42b
22​:32 C<•camelia> rakudo-moar f85978​: OUTPUT«Type check failed in
assignment to $!b; expected <anon> but got Int (42)␤ in block <unit>
at <tmp> line 1␤␤»
22​:33 S<SmokeMachine> Fernando Corrêa de Oliveira m​: class C { has Int
$.a = 42; has Str $.b where $!a }; say C.new.a
22​:33 C<•camelia> rakudo-moar f85978​: OUTPUT«42␤»
22​:33 → pierrot joined ↔ pyrimidine popped in ↔ Ven nipped out
22​:47 S<SmokeMachine> Fernando Corrêa de Oliveira m​: class C { has Int
$.a = 42; has Str $.b where $!a }; say C.new <http://c.new/>&#8203;: :42a
:42b
22​:47 C<•camelia> rakudo-moar f85978​: OUTPUT«Type check failed in
assignment to $!b; expected <anon> but got Int (42)␤ in block <unit>
at <tmp> line 1␤␤»
22​:47 S<SmokeMachine> Fernando Corrêa de Oliveira m​: class C { has Int
$.a = 42; has Int $.b where $!a }; say C.new <http://c.new/>&#8203;: :42a
:42b
22​:47 C<•camelia> rakudo-moar f85978​: OUTPUT«Cannot look up attributes
in a VMNull type object␤ in block <unit> at <tmp> line 1␤␤»

Thank you for the report. This is now fixed. Specifically, it now throws a useful error,
saying `self` is now available inside such a `where` clause.

Fix​: rakudo/rakudo@1c894e418d
Test​: Raku/roast@410a3982c5

@p6rt
Copy link
Author

p6rt commented Feb 9, 2018

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

@p6rt
Copy link
Author

p6rt commented Feb 9, 2018

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

@p6rt p6rt closed this as completed Feb 9, 2018
@p6rt
Copy link
Author

p6rt commented Feb 16, 2018

From @zoffixznet

Correct test link​: Raku/roast@2f70d11

@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