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

Fw: Method 'prime' not found for invocant of class 'Integer' #1447

Closed
p6rt opened this issue Dec 20, 2009 · 6 comments
Closed

Fw: Method 'prime' not found for invocant of class 'Integer' #1447

p6rt opened this issue Dec 20, 2009 · 6 comments

Comments

@p6rt
Copy link

p6rt commented Dec 20, 2009

Migrated from rt.perl.org#71456 (status was 'resolved')

Searchable as RT71456$

@p6rt
Copy link
Author

p6rt commented Dec 20, 2009

From robert_strahl@yahoo.com

# 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" }
}

@p6rt
Copy link
Author

p6rt commented Jul 24, 2010

From @coke

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

@p6rt
Copy link
Author

p6rt commented Jul 24, 2010

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Sep 23, 2011

From @coke

On Sat Jul 24 15​:19​:58 2010, coke wrote​:

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

Another updated version based on current spec​:

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.gist;
  print " $_ is​: ";
  if .prime { say "prime" } else { say "NOT prime" }
}

say "Testing 1..5";
for 1..5 {
  print .WHAT.gist;
  print " $_ is​: ";
  if .prime { say "prime" } else { say "NOT prime" }
}

outputs​:

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​: prime
Int() 3 is​: prime
Int() 4 is​: prime
Int() 5 is​: prime

... quick, test it before the spec changes again.

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Jan 6, 2012

From @moritz

Now tested in t/spec/S12-class/augment-supersede.t.

@p6rt
Copy link
Author

p6rt commented Jan 6, 2012

@moritz - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Jan 6, 2012
@p6rt p6rt added the testneeded label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant