You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this small example, I get an exception where I don't expect one:
role LL[::T] {
has T $.item;
has LL[T] $.next;
method visit(&c) {
c($.item); $.next.visit(&c) if $.next;
}
}
my $t = LL[Int].new(
item => 5,
next => LL[Int].new( item => 4 ),
);
say $t.perl;
$t.visit(&say);
Output:
LL[Int].new(item => 5, next => LL[Int].new(item => 4, next => LL[T]))
5
No such method 'visit' for invocant of type 'Int'
in method visit at role-param-bug.p6 line 6
in block <unit> at role-param-bug.p6 line 15
It calls method visit on an Int, but $.next is a LL[Int], as the .perl
output confirms.
When I add a 'dd $.next' before the dying recursion call, it reports
$.next as Int 4. Which the type constraint shouldn't even allow as value
for $.next.
Other observations:
* changing the name of the attribute doesn't make a difference
* changing $.next.visit(&c) to $!next.visit(&c) makes the error go away.
Migrated from rt.perl.org#130183 (status was 'new')
Searchable as RT130183$
The text was updated successfully, but these errors were encountered: