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

Positional capture of separator on ?% operator causes compiler error #4404

Open
p6rt opened this issue Jul 15, 2015 · 5 comments
Open

Positional capture of separator on ?% operator causes compiler error #4404

p6rt opened this issue Jul 15, 2015 · 5 comments
Labels
regex Regular expressions, pattern matching, user-defined grammars, tokens and rules

Comments

@p6rt
Copy link

p6rt commented Jul 15, 2015

Migrated from rt.perl.org#125618 (status was 'open')

Searchable as RT125618$

@p6rt
Copy link
Author

p6rt commented Jul 15, 2015

From @ShimmerFairy

<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␤»

@p6rt
Copy link
Author

p6rt commented Feb 11, 2018

From @zoffixznet

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 Raku/nqp@ac3d5307f3 and Raku/roast@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​: Raku/roast@aaa71d0#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.

@p6rt
Copy link
Author

p6rt commented Feb 11, 2018

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Feb 11, 2018

From @AlexDaniel

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​:

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
Raku/nqp@ac3d5307f3 and
Raku/roast@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​:
Raku/roast@aaa71d0#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.

@p6rt
Copy link
Author

p6rt commented Feb 11, 2018

From @zoffixznet

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.

@p6rt p6rt added the regex Regular expressions, pattern matching, user-defined grammars, tokens and rules label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
regex Regular expressions, pattern matching, user-defined grammars, tokens and rules
Projects
None yet
Development

No branches or pull requests

1 participant