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
where-clauses in parametric role signatures produce internal error #1186
Comments
From @moritz12:16 <@moritz_> rakudo: role A[Int $x where { $x % 2 == 0 }] { method s { So the where-clauses didn't have the effect of disambiguating the Cheers, -- |
From @kylehaThis is an automatically generated mail to inform you that tests are now available in t/spec/S14-roles/parameterized-type.t commit f1fa89ed11f37183f0126ed779a828fe151303a4 [t/spec] Tests for RT #68074 Inline Patchdiff --git a/t/spec/S14-roles/parameterized-type.t b/t/spec/S14-roles/parameterized-type.t
index 1b3c4d2..5eeff7f 100644
--- a/t/spec/S14-roles/parameterized-type.t
+++ b/t/spec/S14-roles/parameterized-type.t
@@ -2,7 +2,7 @@ use v6;
use Test;
-plan 24;
+plan 28;
=begin pod
@@ -56,6 +56,31 @@ dies_ok { C4.new.call_fail }, 'roles being used as type constraints inside
is R2[C3].new.call_test, 'ok', 'classes being used as type constraints inside roles work';
dies_ok { R2[C3].new.call_fail }, 'classes being used as type constraints inside roles work';
+#?rakudo skip 'RT #68074'
+{
+ role A[Int $x where { $x % 2 == 0 }] {
+ method s { 'even' }
+ }
+ role A[Int $x where { $x % 2 == 1 }] {
+ method s { 'odd' }
+ }
+
+ class RT68074odd does A[5] {}
+
+ my $a;
+ lives_ok { $a = RT68074odd.new.s },
+ 'can call method of class from role with parametric signature using where (odd)'; # and a partridge in a pear tree!
+ is $a, 'odd',
+ 'role disambiguation via parametric signature with where works (odd)';
+
+ class RT68074even does A[74] {}
+
+ lives_ok { $a = RT68074even.new.s },
+ 'can call method of class from role with parametric signature using where (even)';
+ is $a, 'even',
+ 'role disambiguation via parametric signature with where works (even)';
+}
+
#?pugs emit =end SKIP
# vim: ft=perl6 |
The RT System itself - Status changed from 'new' to 'open' |
From @kylehaThis is an automatically generated mail to inform you that tests are now available in t/spec/S14-roles/parameterized-basic.t commit 776faf26ebc889ddc3b194b3e33ff8af136fc953 [t/spec] Tests for RT 68074: class composition time multi dispatch Inline Patchdiff --git a/t/spec/S14-roles/parameterized-basic.t b/t/spec/S14-roles/parameterized-basic.t
index 97eb1cb..b49bb60 100644
--- a/t/spec/S14-roles/parameterized-basic.t
+++ b/t/spec/S14-roles/parameterized-basic.t
@@ -2,7 +2,7 @@ use v6;
use Test;
-plan 22;
+plan 32;
=begin pod
@@ -103,6 +103,53 @@ is(TTP_2.new.x("OH HAI"), 'got a Str() it was OH HAI', 'type variable in scope a
dies_ok({ TTP_1.new.x("OH HAI") }, 'type constraint with parameterized type enforced');
dies_ok({ TTP_2.new.x(42) }, 'type constraint with parameterized type enforced');
+# test multi dispatch on parameterized roles
+# not really basic anymore, but I don't know where else to put these tests
+#?rakudo skip 'composition time multi dispatch with generics/where-blocks'
+{
+ role MD_block[Int $x where { $x % 2 == 0 }] {
+ method what { 'even' };
+ }
+ role MD_block[Int $x where { $x % 2 == 1 }] {
+ method what { 'odd' };
+ }
+
+ class CEven does MD_block[4] { };
+ class COdd does MD_block[3] { };
+
+ is CEven.new.what, 'even',
+ 'multi dispatch on parameterized role works with where-blocks (1)';
+ is COdd.new.what, 'odd',
+ 'multi dispatch on parameterized role works with where-blocks (2)';
+ is CEven.what, 'even',
+ 'same with class methods (1)';
+ is COdd.what, 'odd',
+ 'same with class methods (2)';
+ eval_dies_ok 'class MD_not_Int does MD_block["foo"] { }',
+ "Can't compose without matching role multi";
+
+ role MD_generics[::T $a, T $b] {
+ method what { 'same type' }
+ }
+ role MD_generics[$a, $b] {
+ method what { 'different type' }
+ }
+ class CSame does MD_generics[[], []] { }
+ class CDiff does MD_generics[4, {}] { }
+
+ is CSame.new.what, 'same type',
+ 'MD with generics at class composition time (1)';
+ is CDiff.new.what, 'different type',
+ 'MD with generics at class composition time (2)';
+
+ is CSame.what, 'same type',
+ 'MD with generics at class composition time (class method) (1)';
+ is CDiff.what, 'different type',
+ 'MD with generics at class composition time (class method) (2)';
+ eval_dies_ok 'class WrongFu does MD_generics[3] { }',
+ 'MD with generics at class composition times fails (wrong arity)';
+}
+
#?pugs emit =end SKIP
# vim: ft=perl6 |
From @jnthnOn Fri Jul 31 03:19:31 2009, mlenz@physik.uni-wuerzburg.de wrote:
Some tricky hacking later: role A[Int $x where { $x % 2 == 0 }] { method s { 'even' } } Outputs: odd \o/ Tests turned on, resolving ticket. Thanks, Jonathan |
@jnthn - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#68074 (status was 'resolved')
Searchable as RT68074$
The text was updated successfully, but these errors were encountered: