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

ignoring named arguments if there is an optional positional argument missing #102

Closed
p6rt opened this issue May 25, 2008 · 5 comments
Closed

Comments

@p6rt
Copy link

p6rt commented May 25, 2008

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

Searchable as RT54800$

@p6rt
Copy link
Author

p6rt commented May 25, 2008

From @diakopter

rakudo is currently ignoring named arguments if there is an optional
positional argument missing. Not only does it ignore the passed value
for $y, it also ignores the default value for $y provided in the
declaration.

17​:06
  rakudo​: sub foo(​:$y = 2, $x?){ say "$x""|""$y"}; foo(​:y(3), 1);
17​:06
  exp_evalbot
  OUTPUT[1|3␤]
17​:06
  diakopter
  rakudo​: sub foo($x?, :$y = 2){ say "$x""|""$y"}; foo(​:y(3), 1);
17​:06
  exp_evalbot
  OUTPUT[1|3␤]
17​:06
  diakopter
  rakudo​: sub foo($x?, :$y = 2){ say "$x""|""$y"}; foo(1, :y(3));
17​:06
  exp_evalbot
  OUTPUT[1|3␤]
17​:07
  diakopter
  rakudo​: sub foo(​:$y = 2, $x?){ say "$x""|""$y"}; foo(1, :y(3));
17​:07
  exp_evalbot
  OUTPUT[1|3␤]
17​:07
  diakopter
  yep; that's it. (here's the error - expecting OUTPUT[|3␤])
17​:07

  rakudo​: sub foo($x?, :$y = 2){ say "$x""|""$y"}; foo(​:y(3));
17​:07
  exp_evalbot
  OUTPUT[|␤]

@p6rt
Copy link
Author

p6rt commented May 26, 2008

From @pmichaud

On Sun, May 25, 2008 at 10​:31​:41AM -0700, diakopter wrote​:

rakudo is currently ignoring named arguments if there is an optional
positional argument missing. Not only does it ignore the passed value
for $y, it also ignores the default value for $y provided in the
declaration.

   rakudo​: sub foo\(​:$y = 2, $x?\)\{ say "$x"~"|"~"$y"\}; foo\(​:y\(3\), 1\);
   exp\_evalbot
   OUTPUT\[1|3␤\]

This is a syntax error that rakudo doesn't happen to catch yet.
Perl 6 requires that named parameters follow any required or
optional parameters. (According to STD.pm​:
"Can't use optional positional parameter in variadic zone")

   rakudo​: sub foo\($x?, :$y = 2\)\{ say "$x"~"|"~"$y"\}; foo\(​:y\(3\), 1\);
   exp\_evalbot
   OUTPUT\[1|3␤\]

This looks correct to me.

   rakudo​: sub foo\($x?, :$y = 2\)\{ say "$x"~"|"~"$y"\}; foo\(1, :y\(3\)\);
   exp\_evalbot
   OUTPUT\[1|3␤\]

This also looks correct.

   rakudo​: sub foo\(​:$y = 2, $x?\)\{ say "$x"~"|"~"$y"\}; foo\(1, :y\(3\)\);
   exp\_evalbot
   OUTPUT\[1|3␤\]

"Can't use optional positional parameter in variadic zone"

   rakudo​: sub foo\($x?, :$y = 2\)\{ say "$x"~"|"~"$y"\}; foo\(​:y\(3\)\);
   exp\_evalbot
   OUTPUT\[|␤\]

This appears to be a bug in Parrot (now RT#​54860). When that's fixed
this one should be fixed also.

Pm

@p6rt
Copy link
Author

p6rt commented May 26, 2008

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Sep 9, 2008

From julian.notfound@gmail.com

   rakudo​: sub foo\($x?, :$y = 2\)\{ say "$x"~"|"~"$y"\}; foo\(​:y\(3\)\);
   exp\_evalbot
   OUTPUT\[|␤\]

This appears to be a bug in Parrot (now RT#​54860). When that's fixed
this one should be fixed also.

RT#​54860 is fixed, verified​:

rakudo​: sub foo($x?, :$y = 2){ say "$x""|""$y"}; foo(​:y(3));
OUTPUT[Use of uninitialized value␤|3␤]

@p6rt
Copy link
Author

p6rt commented Mar 31, 2009

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

@p6rt p6rt closed this as completed Mar 31, 2009
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant