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

Name capture happens in the presence of a quantifier but not in its absence in Rakudo #2652

Closed
p6rt opened this issue Feb 22, 2012 · 6 comments

Comments

@p6rt
Copy link

p6rt commented Feb 22, 2012

Migrated from rt.perl.org#111286 (status was 'resolved')

Searchable as RT111286$

@p6rt
Copy link
Author

p6rt commented Feb 22, 2012

From @masak

<cognominal> nom​: (grammar { token TOP { <a>? $<b>='b' }; token a {
a } }).parse​: 'ab'; say $/<b>.keys;
<p6eval> nom 4130f6​: OUTPUT«a␤»
<cognominal> nom​: (grammar { token TOP { <a> $<b>='b' }; token a {
a } }).parse​: 'ab'; say $/<b>.keys;
<p6eval> nom 4130f6​: OUTPUT«␤»
<cognominal> jnthn, this does not make any sense to me that $/<b>.keys
returns anything different than a void Parcel
<cognominal> should I file a bug?
<moritz> nom​: (grammar { token TOP { <a> $<b>='b' }; token a { a }
}).parse​: 'ab'; say $/<b>.keys.WHAT;
<p6eval> nom 4130f6​: OUTPUT«List()␤»
<moritz> cognominal​: it's returns an empty List, not an empty Parcel.
Is that your problem?
<cognominal> see the first example, it prints "a\n".
<cognominal> I don't care if it is a parcel or a list. Whatever it is
should be empty.
<moritz> agreed
<cognominal> it does not happen when I delete the '?' suffix.
<moritz> though of course the ? quantifier on <a> should not affect $<b>
<cognominal> yes, that's my point.
<moritz> agreed. Bug it is.
<cognominal> it took me a while to golf it. Probably because my code
hits other bugs as well.
* masak submits rakudobug

@p6rt
Copy link
Author

p6rt commented Feb 22, 2012

From @cognominal

$ perl6

(grammar { token TOP { <a>? $&lt;b&gt;='b' }; token a { a } }).parse​: 'ab'; say $/<b>.keys;
a
(grammar { token TOP { <a> $&lt;b&gt;='b' }; token a { a } }).parse​: 'ab'; say $/<b>.keys;

In the first line $/<b>.keys is not empty contrary to expectations.
Somehow the results of the <a>?
rule leaks into $/<b>.
Note that in the second line, the question mark in <a>? is suppressed
and the bug is not triggered any more.

Maybe the bug will be fixed when the implementation of ? will be
rewritten as per spec (not returning an array).

<cognominal> nom​: (grammar { token TOP { <a>? $<b>='b' }; token a {
a } }).parse​: 'ab'; say $/<b>.keys;
<p6eval> nom 4130f6​: OUTPUT«a␤»
<cognominal> nom​: (grammar { token TOP { <a> $<b>='b' }; token a {
a } }).parse​: 'ab'; say $/<b>.keys;
<p6eval> nom 4130f6​: OUTPUT«␤»
<cognominal> jnthn, this does not make any sense to me that $/<b>.keys
returns anything different than a void Parcel
<cognominal> should I file a bug?
* NamelessTee has quit (Ping timeout​: 244 seconds)
<moritz> nom​: (grammar { token TOP { <a> $<b>='b' }; token { a }
}).parse​: 'ab'; say $/<b>.keys.WHAT;
<p6eval> nom 4130f6​: OUTPUT«Method 'a' not found for invocant of class
'<anon>'␤ in regex TOP at /tmp/fZXy8AXoHU​:1␤ in method parse at
src/gen/CORE.setting​:8019␤ in block <anon> at /tmp/fZXy8AXoHU​:1␤␤»
<moritz> nom​: (grammar { token TOP { <a> $<b>='b' }; token a { a }
}).parse​: 'ab'; say $/<b>.keys.WHAT;
<p6eval> nom 4130f6​: OUTPUT«List()␤»
<moritz> cognominal​: it's returns an empty List, not an empty Parcel.
Is that your problem?
<cognominal> see the first example, it prints "a\n".
<cognominal> I don't care if it is a parcel or a list. Whatever it is
should be empty.
<moritz> agreed
<cognominal> it does not happen when I delete the '?' suffix.
<moritz> though of course the ? quantifier on <a> should not affect $<b>
<cognominal> yes, that's my point.
<moritz> agreed. Bug it is.

--
cognominal stef

@p6rt
Copy link
Author

p6rt commented May 17, 2012

From @pmichaud

Now fixed in 0ed00f0.... probably needs spectests to close ticket.

Thanks!

Pm

@p6rt
Copy link
Author

p6rt commented May 17, 2012

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

@p6rt
Copy link
Author

p6rt commented May 17, 2012

From @moritz

tested in S05-capture/named.t.

@p6rt
Copy link
Author

p6rt commented May 17, 2012

@moritz - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant