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

Strange return type on &-sigilled attributes with where clauses. #1798

Open
skids opened this issue May 5, 2018 · 1 comment

Comments

Projects
None yet
3 participants
@skids
Copy link
Contributor

commented May 5, 2018

Class attributes with & sigil and a where clause are given a mysterious anon return type.
This prevents them from being initialized.

$ perl6 -e 'class C { has &.c where {.arity == 1}; method foo { &.c.perl.say; }}; C.^attributes.say'
(Callable[<anon>] &!c)
$ perl6 -e 'class C { has &.foo; }; C.new(:foo(sub { })).foo;'
$ perl6 -e 'class C { has &.foo where { True }; }; C.new(:foo(sub { })).foo;'
Type check failed in assignment to &!foo; expected Callable[<anon>] but got Sub (sub () { ...

IRC conversation:
https://irclog.perlgeek.de/perl6/2018-05-05#i_16132944

This only happens to attributes, not class variables.

@zoffixznet

This comment has been minimized.

Copy link
Contributor

commented May 5, 2018

Somewhat related: #1414

But basically in this context, the variable (attribute) is parametarized with anonymous subset with that where clause and the callable being given to it isn't, so it rejects it. If it were possible to use a where in returns portion of a sig, it'd likely accept it.

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.