> On 03 Jan 2016, at 20:59, Zoffix Znet (via RT) <perl6-bugs-follo...@perl.org> 
> wrote:
> 
> # New Ticket Created by  Zoffix Znet 
> # Please include the string:  [perl #127137]
> # in the subject line of all future correspondence about this issue. 
> # <URL: https://rt.perl.org/Ticket/Display.html?id=127137 >
> 
> 
> The error is made when the programmer assumes method declarations without a 
> signature mean any arguments are valid and not a (). This would be common 
> with Perl 5 programmers, I can imagine.
> 
> Moreover, whe error that is shown when a call to such a method is made says 
> it received 1 more argument than what the user provided, and it's not obvious 
> that the one extra is the invocant.
> 
> In constrast, doing the same thing with plain subroutines shows a much 
> clearer and more informative error message.
> 
> 
> <Zoffix> m: class Foo { method bar {say "uhum"} }; Foo.new.bar: 42;
> <camelia> rakudo-moar 4bb47d: OUTPUT«Too many positionals passed; expected 1 
> argument but got 2␤  in method bar at /tmp/fub1N6RN3q line 1␤  in block 
> <unit> at /tmp/fub1N6RN3q line 1␤␤»

This *also* applies when there *is* a signature specified.

$ 6 'class Foo { method bar() {say "uhum"} }; Foo.new.bar: 42'
Too many positionals passed; expected 1 argument but got 2
  in method bar at -e line 1
  in block <unit> at -e line 1

So, the LTAness of this error message is more generic.  I’ll see if I can do 
something about that.


> <Zoffix> m: sub bar { say "uhum" }; bar 42
> <camelia> rakudo-moar 4bb47d: OUTPUT«===SORRY!=== Error while compiling 
> /tmp/V0xL_4prhM␤Calling bar(Int) will never work with declared signature 
> ()␤at /tmp/V0xL_4prhM:1␤------> sub bar { say "uhum" }; ⏏bar 42␤»

This is possible because the optimizer can figure this out at compile time.  
It’s not possible (yet, anyway) to do this for methods.  It will probably be 
quite some time before we will see this type of message for method calls  :-(



Liz

Reply via email to