Skip Menu |
Report information
Id: 129768
Status: new
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: masak <cmasak [at] gmail.com>
Cc:
AdminCc:

Severity: (no value)
Tag: Bug
Platform: (no value)
Patch Status: (no value)
VM: (no value)



From: Carl Mäsak <cmasak [...] gmail.com>
To: rakudobug [...] perl.org
Subject: [BUG] Wrong error message when (disallowed) positional slurpy with a default is preceded by named in Rakudo
Date: Fri, 30 Sep 2016 23:21:38 +0200
Download (untitled) / with headers
text/plain 1.4k
<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


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org