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

:i modifier precedence on alternations #2031

Closed
p6rt opened this issue Aug 7, 2010 · 5 comments
Closed

:i modifier precedence on alternations #2031

p6rt opened this issue Aug 7, 2010 · 5 comments

Comments

@p6rt
Copy link

p6rt commented Aug 7, 2010

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

Searchable as RT77064$

@p6rt
Copy link
Author

p6rt commented Aug 7, 2010

From oha@oha.it

i expected that both the following should fails​:

say 'X' if 'bar' ~~ /​:i FOO || BAR/; # only FOO modified by :i
say 'Y' if 'Y' ~~ /​:i || FOO || BAR/; # i expected the first alternation
empty (and skipped then)

and i expected the following to match, but isn't​:

say 'Z' if 'Ab' eq 'Ab' ~~ / A :i B || C /

@p6rt
Copy link
Author

p6rt commented Nov 13, 2011

From @coke

On Sat Aug 07 02​:43​:43 2010, oha.it wrote​:

i expected that both the following should fails​:

say 'X' if 'bar' ~~ /​:i FOO || BAR/; # only FOO modified by :i
say 'Y' if 'Y' ~~ /​:i || FOO || BAR/; # i expected the first alternation
empty (and skipped then)

and i expected the following to match, but isn't​:

say 'Z' if 'Ab' eq 'Ab' ~~ / A :i B || C /

Some more recent output​:

19​:06 <@​Coke> nom​: say 'X' if 'bar' ~~ /​:i FOO || BAR/;
19​:06 <+p6eval> nom ef4702​: ( no output )
19​:07 <@​Coke> nom​: say 'X' if 'BAR' ~~ /​:i FOO || BAR/;
19​:07 <+p6eval> nom ef4702​: OUTPUT«X␤»
19​:07 <@​Coke> nom​: say 'X' if 'foo' ~~ /​:i FOO || BAR/;
19​:07 <+p6eval> nom ef4702​: ( no output )
19​:08 <@​Coke> nom​: say 'Z' if 'Ab' eq 'Ab' ~~ / A :i B || C /
19​:08 <+p6eval> nom ef4702​: ( no output )

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Nov 13, 2011

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

@p6rt
Copy link
Author

p6rt commented Jan 1, 2015

From @moritz

Hi,

On Sat Aug 07 02​:43​:43 2010, oha.it wrote​:

i expected that both the following should fails​:

say 'X' if 'bar' ~~ /​:i FOO || BAR/; # only FOO modified by :i
say 'Y' if 'Y' ~~ /​:i || FOO || BAR/; # i expected the first alternation
empty (and skipped then)

I regret to inform you that your expectations aren't backed by S05; it indicates that :i is lexically scoped, and that subrules and [] and () introduce lexical scopes; I see no indication that || introduces lexical scopes.

and i expected the following to match, but isn't​:

say 'Z' if 'Ab' eq 'Ab' ~~ / A :i B || C /

Assuming the eq is a mistake, this has now been fixed (by NQP commit b924e932). (It was an over-eager optimization that concatenated consecutive literals, and didn't check whether :i changed for them)

Cheers,
Moritz

@p6rt
Copy link
Author

p6rt commented Jan 1, 2015

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

@p6rt p6rt closed this as completed Jan 1, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant