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