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

Wrong error message when (disallowed) positional slurpy with a default is preceded by named in Rakudo #5708

Open
p6rt opened this issue Sep 30, 2016 · 1 comment
Labels

Comments

@p6rt
Copy link

p6rt commented Sep 30, 2016

Migrated from rt.perl.org#129768 (status was 'new')

Searchable as RT129768$

@p6rt
Copy link
Author

p6rt commented Sep 30, 2016

From @masak

<seatek> Hello :) So, wondering if anyone might know - in a parameter
signature, if you have a slurpy array (*@​thing) -- is there a way to
define a default set of values for it, if nothing gets slurped up?
<seatek> sub MAIN ( Str :$log-file = 'blah', Bool :$thing = False,
@​srcDirs = ('/tmp', '/var/log' ))
<seatek> that would give the error
<seatek> Cannot put optional positional parameter @​srcDirs after
variadic parameters
<seatek> and if you give it the slurpy splat, it's the same error message
<masak> seatek​: I agree that "it's the same error message" is more
confusing than it has to be
<masak> m​: sub MAIN (​:$named, *@​srcDirs = ("/tmp", "/var/log" )) {}
<camelia> rakudo-moar 83d733​: OUTPUT«===SORRY!=== Error while
compiling <tmp>␤Cannot put optional positional parameter @​srcDirs
after variadic parameters [...]
<masak> seatek​: what it really should do in the case of the slurpy is
to give you the error "Cannot put default on slurpy parameter
@​srcDirs"
<masak> m​: sub MAIN (*@​srcDirs = ("/tmp", "/var/log" )) {}
21​:07 <+camelia> rakudo-moar 83d733​: OUTPUT«===SORRY!=== Error while
compiling <tmp>␤Cannot put default on slurpy parameter @​srcDirs [...]
<masak> ...which it does if you don't put named parameters before it
<masak> seatek​: I think as to your original question -- whether it's
supported -- the answer is no because you basically can not *not* pass
in a set of values to the slurpy parameter.
<seatek> masak​: yeah, that makes complete sense when you really think about it

@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant