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
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)
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.
-zefram
The text was updated successfully, but these errors were encountered: