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

Method lookup meta-error on classes #1009

Open
Util opened this issue Oct 7, 2013 · 0 comments
Open

Method lookup meta-error on classes #1009

Util opened this issue Oct 7, 2013 · 0 comments

Comments

@Util
Copy link
Member

Util commented Oct 7, 2013

Reported by: zefram@fysh.org

When a named method is called on an object, but the invocant class doesn't define a method of that name, an error message is generated. Normally the error message refers to the class of the invocant, but if the invocant is a class object then the error message gets it wrong: it shows the name of the class represented by the invocant object instead of the class of the invocant. If the invocant is an anonymous class then a completely different error message is generated.

In these examples (correct behaviour and then the two incorrect cases), I use typeof on the invocant to show what class name should appear in the error message that comes from the method call.

$ cat t48.pir 
.sub main :main
       $P0 = newclass "Foo"
       $P1 = new $P0
       $S0 = typeof $P1
       say $S0
       $P2 = $P1."wibble"()
.end
$ ./parrot t48.pir 
Foo
Method 'wibble' not found for invocant of class 'Foo'
current instr.: 'main' pc 17 (t48.pir:6)
$ cat t47.pir 
.sub main :main
       $P0 = newclass "Foo"
       $P1 = subclass $P0, "Bar"
       $S0 = typeof $P1
       say $S0
       $P2 = $P1."wibble"()
.end
$ ./parrot t47.pir 
Class
Method 'wibble' not found for invocant of class 'Bar'
current instr.: 'main' pc 18 (t47.pir:6)
$ cat t45.pir 
.sub main :main
       $P0 = newclass "Foo"
       $P1 = subclass $P0
       $S0 = typeof $P1
       say $S0
       $P2 = $P1."wibble"()
.end
$ ./parrot t45.pir 
Class
Attempt to create PMC Proxy for invalid type number = 0!
current instr.: 'main' pc 17 (t45.pir:6)

-zefram

Summary of my parrot 5.7.0 configuration:
 configdate='Sat Oct  5 12:42:43 2013 GMT'
 Platform:
   osname=linux, archname=x86_64-linux-gnu-thread-multi
   perl=/usr/bin/perl
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