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
sub MAIN cannot accept enum argument #5808
Comments
From @titsukiSee the following results: $ perl6 script.p6 --country=America $ perl6 script.p6 --country=1 script.p6: use v6; enum Country<China America Brazil>; sub MAIN(Country :$country!) { $ perl6 --version I think that if sub MAIN cannot accept enum argument, it should display any error messages and die. |
From @lizmatThe 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: but I guess that’s the best we have for this in the short-term.
|
The RT System itself - Status changed from 'new' to 'open' |
From @lizmatAfter some more investigation it turned out to be not so difficult in the MAIN parameter
|
From @zoffixznetTests added in Raku/roast@8ff3ab7391 |
@zoffixznet - Status changed from 'open' to 'resolved' |
From @zoffixznetI'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. |
1 similar comment
From @zoffixznetI'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. |
@zoffixznet - Status changed from 'resolved' to 'open' |
Migrated from rt.perl.org#130131 (status was 'open')
Searchable as RT130131$
The text was updated successfully, but these errors were encountered: