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

Accessor use (correctly) forbidden in submethod body but (mistakenly) allowed in parameter default expression in Rakudo #4390

Closed
p6rt opened this issue Jul 10, 2015 · 4 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Jul 10, 2015

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

Searchable as RT125591$

@p6rt
Copy link
Author

p6rt commented Jul 10, 2015

From @masak

<masak> m​: class C { has $.x = 42; submethod BUILD(​:$.x) {} }; say C.new.x
<camelia> rakudo-moar fadca9​: OUTPUT«Cannot find method 'STORE'␤ in
submethod BUILD [...]
<masak> m​: class C { has $.x = 42; submethod BUILD(​:$!x = 5) { $.x }
}; say C.new.x
<camelia> rakudo-moar fadca9​: OUTPUT«===SORRY!=== Error [...] Virtual
call $.x may not be used on partially constructed objects [...]
<masak> that "Virtual call" error message should probably happen for
:$.x as well...
* masak submits rakudobug

Even if using :$.x in a parameter list in a submethod is OK, the error
message "Cannot find method 'STORE'" is rather less-than-awesome and
mysterious as it stands.

@p6rt
Copy link
Author

p6rt commented Jul 15, 2015

From @jnthn

On Fri Jul 10 07​:02​:13 2015, masak wrote​:

<masak> m​: class C { has $.x = 42; submethod BUILD(​:$.x) {} }; say C.new.x
<camelia> rakudo-moar fadca9​: OUTPUT«Cannot find method 'STORE'␤ in
submethod BUILD [...]
<masak> m​: class C { has $.x = 42; submethod BUILD(​:$!x = 5) { $.x }
}; say C.new.x
<camelia> rakudo-moar fadca9​: OUTPUT«===SORRY!=== Error [...] Virtual
call $.x may not be used on partially constructed objects [...]
<masak> that "Virtual call" error message should probably happen for
:$.x as well...
* masak submits rakudobug

Even if using :$.x in a parameter list in a submethod is OK, the error
message "Cannot find method 'STORE'" is rather less-than-awesome and
mysterious as it stands.

Well, nothing too mysterious in so far as we're not initialized enough yet to have storage set up. But yeah, it should never make it that far. Now​:

===SORRY!=== Error while compiling -e
Virtual call $.x may not be used on partially constructed objects
at -e​:1
------> s C { has $.x = 42; submethod BUILD(​:$.x<HERE>) {} }

Test added to S12-methods/attribute-params.t.

@p6rt
Copy link
Author

p6rt commented Jul 15, 2015

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

@p6rt p6rt closed this as completed Jul 15, 2015
@p6rt
Copy link
Author

p6rt commented Jul 15, 2015

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

@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