Skip Menu |
Report information
Id: 130131
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: cookbook_000 [at] yahoo.co.jp <titsuki [at] cpan.org>
Cc:
AdminCc:

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



From: cookbook_000 [...] yahoo.co.jp
Date: Fri, 18 Nov 2016 23:40:05 +0900 (JST)
To: "rakudobug [...] perl.org" <rakudobug [...] perl.org>
Subject: [LTA][BUG] sub MAIN cannot accept enum argument
Download (untitled) / with headers
text/plain 534b
See the following results: $ perl6 script.p6 --country=America Usage:   script.p6 --country=<Country>  $ perl6 script.p6 --country=1 Usage:   script.p6 --country=<Country>  script.p6: ---- use v6; enum Country<China America Brazil>; sub MAIN(Country :$country!) {     say $country; } ---- $ perl6 --version This is Rakudo version 2016.10-295-g85c7072 built on MoarVM version 2016.10-71-g9d5c874 implementing Perl 6.c. I think that if sub MAIN cannot accept enum argument, it should display any error messages and die.
From: Elizabeth Mattijsen <liz [...] dijkmat.nl>
Date: Fri, 18 Nov 2016 17:53:23 +0100
To: "Itsuki Toyota (via RT)" <perl6-bugs-followup [...] perl.org>
Subject: Re: [perl #130131] [LTA][BUG] sub MAIN cannot accept enum argument
Download (untitled) / with headers
text/plain 1.5k
The parameters received from the command line, are always Str (or IntStr if they look like an integer). To allow direct matching / handling of this, we would need something like an EnumStr type. I don’t think that’s going to happen soon. I also tried some pre-processing on the @*ARGS array in an INIT block, but that fails because the default command line processing really expects something that works like a Str. So, so far I’ve only been able to come up with this workaround: sub MAIN(:$country! where (Country.enums{$_}:exists)) { … } Unfortunately it will display the feedback on a wrong parameter like: Usage: script.pl --country=<Any> but I guess that’s the best we have for this in the short-term. Show quoted text
> On 18 Nov 2016, at 15:40, Itsuki Toyota (via RT) <perl6-bugs-followup@perl.org> wrote: > > # New Ticket Created by Itsuki Toyota > # Please include the string: [perl #130131] > # in the subject line of all future correspondence about this issue. > # <URL: https://rt.perl.org/Ticket/Display.html?id=130131 > > > See the following results: > > $ perl6 script.p6 --country=America > Usage: > script.p6 --country=<Country> > > $ perl6 script.p6 --country=1 > Usage: > script.p6 --country=<Country> > > > script.p6: > ---- > use v6; > > enum Country<China America Brazil>; > > sub MAIN(Country :$country!) { > say $country; > } > ---- > > $ perl6 --version > This is Rakudo version 2016.10-295-g85c7072 built on MoarVM version 2016.10-71-g9d5c874 > implementing Perl 6.c. > > > I think that if sub MAIN cannot accept enum argument, it should display any error messages and die.
Subject: Re: [perl #130131] [LTA][BUG] sub MAIN cannot accept enum argument
From: Elizabeth Mattijsen <liz [...] dijkmat.nl>
Date: Fri, 18 Nov 2016 20:53:43 +0100
To: "Itsuki Toyota (via RT)" <perl6-bugs-followup [...] perl.org>
After some more investigation it turned out to be not so difficult in the MAIN parameter handling case. So, fixed with 546dbd99b18425a42c8 . Tests needed! Show quoted text
> On 18 Nov 2016, at 15:40, Itsuki Toyota (via RT) <perl6-bugs-followup@perl.org> wrote: > > # New Ticket Created by Itsuki Toyota > # Please include the string: [perl #130131] > # in the subject line of all future correspondence about this issue. > # <URL: https://rt.perl.org/Ticket/Display.html?id=130131 > > > > See the following results: > > $ perl6 script.p6 --country=America > Usage: > script.p6 --country=<Country> > > $ perl6 script.p6 --country=1 > Usage: > script.p6 --country=<Country> > > > script.p6: > ---- > use v6; > > enum Country<China America Brazil>; > > sub MAIN(Country :$country!) { > say $country; > } > ---- > > $ perl6 --version > This is Rakudo version 2016.10-295-g85c7072 built on MoarVM version 2016.10-71-g9d5c874 > implementing Perl 6.c. > > > I think that if sub MAIN cannot accept enum argument, it should display any error messages and die. >
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 281b
I'm re-opening this, as the Enum conversion is too eager now: https://irclog.perlgeek.de/perl6-dev/2016-11-19#i_13595331 Basically, now MAIN can never take strings False or True, because those get converted to Bools and any other enums will fail to match, unless they're expected.


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