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

skids opened this issue May 5, 2018 · 1 comment


None yet
3 participants
Copy link

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; }; { })).foo;'
$ perl6 -e 'class C { has &.foo where { True }; }; { })).foo;'
Type check failed in assignment to &!foo; expected Callable[<anon>] but got Sub (sub () { ...

IRC conversation:

This only happens to attributes, not class variables.


This comment has been minimized.

Copy link

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.