On Sat Dec 19 19:02:49 2009, vamped wrote: > # yahoo sent the first copy before I finished, arg! > # ignore first email > # > # bug commented in code > > use v6; > > class Int is also { > method prime() { > return True; # actual test algorithm removed for clarity > } > } > > # This loop works > say "Testing 1,2,3,4,5"; > for 1,2,3,4,5 { > print "$_ is: "; > if .prime { say "prime" } else { say "NOT prime" } > } > say ""; > > # This loop doesn't work > # Output: > ## 1 is: prime > ## 2 is: Method 'prime' not found for invocant of class 'Integer' in > Main (file src/gen_setting.pm, line 324) > # > # fwiw - calling the method with a negative int also produces this > error. > # what is "class 'Integer'" ? I thought it was class "Int" in Perl 6. > > say "Testing 1..5"; > for 1..5 { > print "$_ is: "; > if .prime { say "prime" } else { say "NOT prime" } > } > Here's a slightly updated code snippet that exhibit a similar problem:
┗━$━∫ cat foo.p6 use MONKEY_TYPING; augment class Int { method prime() { return True; # actual test algorithm removed for clarity } } say "Testing 1,2,3,4,5"; for 1,2,3,4,5 { print $_.WHAT; print " $_ is: "; if .prime { say "prime" } else { say "NOT prime" } } say "Testing 1..5"; for 1..5 { print $_.WHAT; print " $_ is: "; if .prime { say "prime" } else { say "NOT prime" } } ┗━$━∫ ./perl6 foo.p6 Testing 1,2,3,4,5 Int() 1 is: prime Int() 2 is: prime Int() 3 is: prime Int() 4 is: prime Int() 5 is: prime Testing 1..5 Int() 1 is: prime Int() 2 is: Method 'prime' not found for invocant of class 'Integer' in <anon> at line 21:foo.p6 in main program body at line 1 -- Will "Coke" Coleda