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
Something quite scary happens when the wrong number of positional parameters is sent to a method or sub with a hash param in Rakudo #1452
Comments
From @masak<masak> rakudo: class A { method foo($_: $b) {} }; A.new.foo(1, 2) |
From @jnthnOn Sun Dec 20 13:52:01 2009, masak wrote:
Fixed this one a couple of weeks ago, but failed to find the ticket.
And:
Given to moritz++ for a spectest; checking that %h features somewhere in Thanks, Jonathan |
The RT System itself - Status changed from 'new' to 'open' |
From @kylehaThis is an automatically generated mail to inform you that tests are now available in t/spec/S06-signature/errors.t commit eb0fb473ff6dfd31d3a250ee6878793de81360c4 [t/spec] test for RT #71478, sensible error message for passing two arguments to one hash parameter Inline Patchdiff --git a/t/spec/S06-signature/errors.t b/t/spec/S06-signature/errors.t
index 1ee9f31..439be84 100644
--- a/t/spec/S06-signature/errors.t
+++ b/t/spec/S06-signature/errors.t
@@ -1,8 +1,8 @@
-use v6;
+ use v6;
use Test;
-plan 5;
+ plan 9;
=begin pod
@@ -15,7 +15,7 @@ sub foo (*$x) { 1 }
dies_ok { foo(reverse(1,2)) }, 'slurpy args are now bounded (1)';
sub bar (*@x) { 1 }
-lives_ok { bar(reverse(1,2)) }, 'slurpy args are now bounded (2)';
+lives_ok { bar(reverse(1,2)) }, 'slurpy args are not bounded (2)';
eval_dies_ok 'sub quuux ($?VERSION) { ... }',
'parser rejects magicals as args (1)';
@@ -30,4 +30,15 @@ eval_dies_ok('sub quuuux ($!) { ... }',
'argument passed to sub with empty signature';
}
+# RT #71478
+{
+ my $success = eval 'sub foo(%h) { }; foo(1, 2); 1';
+ my $error = "$!";
+ nok $success,
+ "Passing two arguments to a function expecting one hash is an error";
+ ok $error ~~ / '%h' /, '... error message mentions parameter';
+ ok $error ~~ /:i 'type' /, '... error message mentions "type"';
+ ok $error ~~ / Associative /, '... error message mentions "Associative"';
+}
+
# vim: ft=perl6 |
@moritz - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#71478 (status was 'resolved')
Searchable as RT71478$
The text was updated successfully, but these errors were encountered: