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

Optional parameters before required shouldn't be allowed, but Rakudo doesn't catch them #1431

Closed
p6rt opened this issue Dec 8, 2009 · 6 comments

Comments

@p6rt
Copy link

p6rt commented Dec 8, 2009

Migrated from rt.perl.org#71110 (status was 'resolved')

Searchable as RT71110$

@p6rt
Copy link
Author

p6rt commented Dec 8, 2009

From @masak

<masak> rakudo​: sub foo($a = 1, $b) { say $a }; foo(3)
<p6eval> rakudo 7ef386​: Not enough positional parameters passed; got 1
but expected between 1 and 2 [...]
* masak submits rakudobug
<masak> ng​: sub foo($a = 1, $b) { say $a }; foo(3)
<p6eval> ng 153b18​: Not enough positional parameters passed; got 1 but
expected between 1 and 2 [...]

First off, the error message is nonsensical.

Second, the declaration of a signature where optional parameters
preceed required ones should be rejected at compile-time, but the
error message comes from calling the routine at runtime.

@p6rt
Copy link
Author

p6rt commented Jul 29, 2010

@coke - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented May 13, 2011

From @jnthn

On Mon Dec 07 20​:47​:17 2009, masak wrote​:

<masak> rakudo​: sub foo($a = 1, $b) { say $a }; foo(3)
<p6eval> rakudo 7ef386​: Not enough positional parameters passed; got 1
but expected between 1 and 2 [...]
* masak submits rakudobug
<masak> ng​: sub foo($a = 1, $b) { say $a }; foo(3)
<p6eval> ng 153b18​: Not enough positional parameters passed; got 1 but
expected between 1 and 2 [...]

First off, the error message is nonsensical.

Second, the declaration of a signature where optional parameters
preceed required ones should be rejected at compile-time, but the
error message comes from calling the routine at runtime.

Now​:

15​:29 < jnthn> rakudo​: sub foo($a = 1, $b) { say $a }; foo(3)
15​:29 <+p6eval> rakudo 678ad3​: OUTPUT«===SORRY!===␤Cannot put required
  parameter after optional parameters at line 22, near ")
{ say $a"␤»

Which is the correct error. Needs a test.

/jnthn

@p6rt
Copy link
Author

p6rt commented Sep 11, 2011

From @bbkr

NOM​: works correct

bbkr​:nom bbkr$ ./perl6 -e 'sub foo($a = 1, $b) { say $a }; foo(3)'
===SORRY!===
Cannot put required parameter after optional parameters at line 1, near
") { say $a"

@p6rt
Copy link
Author

p6rt commented Sep 30, 2011

From @moritz

Now tested in t/spec/S06-signature/optional.t

@p6rt
Copy link
Author

p6rt commented Sep 30, 2011

@moritz - Status changed from 'open' to 'resolved'

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