# New Ticket Created by Moritz Lenz # Please include the string: [perl #130183] # in the subject line of all future correspondence about this issue. # <URL: https://rt.perl.org/Ticket/Display.html?id=130183 >
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. Cheers, Moritz -- Moritz Lenz https://deploybook.com/ -- https://perlgeek.de/ -- https://perl6.org/