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

Owner: Nobody
Requestors: lue <rnddim [at] gmail.com>
Cc:
AdminCc:

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



Subject: Positional capture of separator on ?% operator causes compiler error
Download (untitled) / with headers
text/plain 704b
<ShimmerFairy> m: say "ab" ~~ /^ a +% (b) $/ <camelia> rakudo-moar e4077e: OUTPUT«Nil␤» <ShimmerFairy> m: say "ab" ~~ /^ a *% (b) $/ <camelia> rakudo-moar e4077e: OUTPUT«Nil␤» <ShimmerFairy> m: say "ab" ~~ /^ a ?% (b) $/ <camelia> rakudo-moar e4077e: OUTPUT«===SORRY!===␤QAST::Block with cuid cuid_1_1436969557.11546 has not appeared␤» On JVM: <ShimmerFairy> j: say "ab" ~~ /^ a ?% (b) $/ <camelia> rakudo-jvm e4077e: OUTPUT«===SORRY!===␤setcodeobj can only be used with a CodeRef␤» And just to show that it's not just the ?% operator alone contributing to the issue, but the capture too: <ShimmerFairy> m: say "ab" ~~ /^ a ?% [b] $/ <camelia> rakudo-moar e4077e: OUTPUT«Nil␤»
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 1.3k
On Wed, 15 Jul 2015 07:31:55 -0700, lue wrote: Show quoted text
> <ShimmerFairy> m: say "ab" ~~ /^ a +% (b) $/ > <camelia> rakudo-moar e4077e: OUTPUT«Nil␤» > <ShimmerFairy> m: say "ab" ~~ /^ a *% (b) $/ > <camelia> rakudo-moar e4077e: OUTPUT«Nil␤» > <ShimmerFairy> m: say "ab" ~~ /^ a ?% (b) $/ > <camelia> rakudo-moar e4077e: OUTPUT«===SORRY!===␤QAST::Block with > cuid cuid_1_1436969557.11546 has not appeared␤» > > On JVM: > > <ShimmerFairy> j: say "ab" ~~ /^ a ?% (b) $/ > <camelia> rakudo-jvm e4077e: OUTPUT«===SORRY!===␤setcodeobj can only > be used with a CodeRef␤» > > And just to show that it's not just the ?% operator alone contributing > to the issue, but the capture too: > > <ShimmerFairy> m: say "ab" ~~ /^ a ?% [b] $/ > <camelia> rakudo-moar e4077e: OUTPUT«Nil␤»
Made potential fix in branches in https://github.com/perl6/nqp/commit/ac3d5307f3 and https://github.com/perl6/roast/commit/f2b07afbba The fix is to throw on `?`/`??` quantifiers used with `%`/`%%`. It's blocked by 2 lines of 6.c tests that indirectly use this combination: https://github.com/perl6/roast/commit/aaa71d077431cd0a86be84bd386e1032a12e8697#diff-ae7b47444302486e790af6ee18121fabR16 I delegated it to the release manager whether to merge that stuff or to require a fix that leaves these working and then we fix the compilation error itself.
So I looked at this, and at very best the proposed error message is wrong. It says that ? is useless when used with %%, but that's not the case:

<AlexDaniel> m: say ‘af’|‘a’|‘f’|‘’ ~~ /a? %% f/
<camelia> rakudo-moar 00af9ce27: OUTPUT: «「af」␤「a」␤「f」␤「」␤»
<AlexDaniel> m: say ‘af’|‘a’|‘f’|‘’ ~~ /a?f?/
<camelia> rakudo-moar 00af9ce27: OUTPUT: «「af」␤「a」␤「f」␤「」␤»

So yes, while in this case it is equivalent to just `a?f?`, it's not totally useless. And I think it makes sense to allow this behavior to have all quantifiers behaving consistently.

And according to this discussion, that particular fix will not go in: https://irclog.perlgeek.de/perl6-dev/2018-02-11#i_15804761

On 2018-02-11 02:04:06, cpan@zoffix.com wrote:
Show quoted text
> On Wed, 15 Jul 2015 07:31:55 -0700, lue wrote:
> > <ShimmerFairy> m: say "ab" ~~ /^ a +% (b) $/
> > <camelia> rakudo-moar e4077e: OUTPUT«Nil␤»
> > <ShimmerFairy> m: say "ab" ~~ /^ a *% (b) $/
> > <camelia> rakudo-moar e4077e: OUTPUT«Nil␤»
> > <ShimmerFairy> m: say "ab" ~~ /^ a ?% (b) $/
> > <camelia> rakudo-moar e4077e: OUTPUT«===SORRY!===␤QAST::Block with
> > cuid cuid_1_1436969557.11546 has not appeared␤»
> >
> > On JVM:
> >
> > <ShimmerFairy> j: say "ab" ~~ /^ a ?% (b) $/
> > <camelia> rakudo-jvm e4077e: OUTPUT«===SORRY!===␤setcodeobj can only
> > be used with a CodeRef␤»
> >
> > And just to show that it's not just the ?% operator alone
> > contributing
> > to the issue, but the capture too:
> >
> > <ShimmerFairy> m: say "ab" ~~ /^ a ?% [b] $/
> > <camelia> rakudo-moar e4077e: OUTPUT«Nil␤»
>
>
> Made potential fix in branches in
> https://github.com/perl6/nqp/commit/ac3d5307f3 and
> https://github.com/perl6/roast/commit/f2b07afbba
>
> The fix is to throw on `?`/`??` quantifiers used with `%`/`%%`.
>
> It's blocked by 2 lines of 6.c tests that indirectly use this
> combination:
> https://github.com/perl6/roast/commit/aaa71d077431cd0a86be84bd386e1032a12e8697#diff-
> ae7b47444302486e790af6ee18121fabR16
>
> I delegated it to the release manager whether to merge that stuff or
> to require a fix that leaves these working and then we fix the
> compilation error itself.


Download (untitled) / with headers
text/plain 137b
Show quoted text
> Made potential fix in branches in
We decided not to go with that fix in the end. The QAST::Block issue still needs to be addressed.


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