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

Return type constraint check fails with parametrized role #1417

Altai-man opened this Issue Jan 18, 2018 · 3 comments


None yet
3 participants
Copy link

Altai-man commented Jan 18, 2018

The Problem

role A[::RType] {
    method b(RType $foo --> Str) { "String" }
    method a(--> RType) {; }

class B {};

class C does A[B] {}

say C.b(;
say C.a;

Expected Behavior

Both b and a methods work.

Actual Behavior

➜  ~ perl6 I_contain_code_above.pl6 
Died with X::TypeCheck::Return
  in method a at perl6.pl6 line 3
  in block <unit> at perl6.pl6 line 11

So it's ok to use role parameter everywhere, but setting it as a return constraint doesn't work.

Steps to Reproduce

1)Run gist above.

As a quick one-liner, this code shows the issue too: role A[::Ret] { method a(--> Ret) { } }; class B{}; class C does A[B] {}; say C.a;.


  • Operating system: Linux miskatonic 4.14.13_2 #1 SMP PREEMPT Mon Jan 15 01:41:56 UTC 2018 x86_64 GNU/Linux
  • Compiler version (perl6 -v): This is Rakudo version 2017.12 built on MoarVM version 2017.12

This comment has been minimized.

Copy link

TopherCooper commented Jan 10, 2019

See also #2595, a broader version of this problem. Includes a workaround technique.


This comment has been minimized.

Copy link

FCO commented Jan 14, 2019


This comment has been minimized.

Copy link

FCO commented Jan 14, 2019

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.