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

Odd regex behavior with indirect subrule calls to strings #3176

Closed
p6rt opened this issue Jun 30, 2013 · 3 comments
Closed

Odd regex behavior with indirect subrule calls to strings #3176

p6rt opened this issue Jun 30, 2013 · 3 comments

Comments

@p6rt
Copy link

p6rt commented Jun 30, 2013

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

Searchable as RT118697$

@p6rt
Copy link
Author

p6rt commented Jun 30, 2013

From jercos@gmail.com

From freenode's #perl6​:

19​:11 < jercos> r​: my $x = "'foo'|'bar'";("lol foo lol" ~~ /<$x>/).print
19​:11 <+camelia> rakudo 211854​: OUTPUT«foo»
19​:11 < jercos> r​: my $x = "'foo'|'bar'";("lol foo bar" ~~ /<$x>/).print
19​:11 <+camelia> rakudo 211854​: OUTPUT«lol»
19​:11 < jercos> :|
19​:12 < timotimo> a junction is not what you want in this case
19​:12 < timotimo> but try this​:
19​:12 < timotimo> er, i didn't see the " around it, sorry
19​:12 < timotimo> er, what is going on there? o_O
19​:17 < FROGGS> hmm
19​:17 < FROGGS> r​: my $x = "'foo'|'bar'";say "lol foo bar" ~~ /<$x>/
19​:17 <+camelia> rakudo 211854​: OUTPUT«「lol」␤␤»
19​:17 < FROGGS> r​: my $x = "'foo'|'bar'"; "lol foo bar" ~~ /<$x>/; say $/
19​:17 <+camelia> rakudo 211854​: OUTPUT«「lol」␤␤»
19​:17 < FROGGS> r​: my $x = "'foo'|'bar'"; "lol foo bar" ~~ /<$x>/; say $/.MATCH
19​:17 <+camelia> rakudo 211854​: OUTPUT«No such method 'MATCH' for invocant of type 'Match'␤ in block at /tmp/yXMKPuD5qQ​:1␤␤»
19​:17 < FROGGS> err
19​:18 < FROGGS> r​: my $x = "'foo'|'bar'"; "lol foo bar" ~~ /(<$x>)/; say $/.caps
19​:18 <+camelia> rakudo 211854​: OUTPUT«0 => Match.new(orig => "lol foo bar", from => 0, to => 3, ast => Any, list => ().list, hash => EnumMap.new())␤»
19​:18 < FROGGS> r​: my $x = "'foo'|'bar'"; "loll foo bar" ~~ /(<$x>)/; say $/.caps
19​:18 <+camelia> rakudo 211854​: OUTPUT«0 => Match.new(orig => "loll foo bar", from => 0, to => 3, ast => Any, list => ().list, hash => EnumMap.new())␤»
19​:19 < FROGGS> r​: my $x = "'foo'"; "loll foo bar" ~~ /<$x>/; say $/
19​:19 <+camelia> rakudo 211854​: OUTPUT«「foo」␤␤»
19​:19 < FROGGS> r​: my $x = "'foo'"; "lol foo bar" ~~ /<$x>/; say $/
19​:19 <+camelia> rakudo 211854​: OUTPUT«「foo」␤␤»
19​:19 < FROGGS> r​: my $x = "'foo'||'bar'"; "lol foo bar" ~~ /<$x>/; say $/
19​:19 <+camelia> rakudo 211854​: OUTPUT«「lol」␤␤»
19​:20 < FROGGS> r​: my $x = "'foo' ~ 'bar'"; "lol foo bar" ~~ /<$x>/; say $/
19​:20 <+camelia> rakudo 211854​: OUTPUT«===SORRY!===␤Unrecognized regex metacharacter ~ (must be quoted to match literally)␤at eval_0​:1␤------> my $x = anon regex { ^'foo' ~ 'bar' ⏏}␤Malformed regex␤at eval_0​:1␤------> my $x = anon regex { ^'foo' ~ 'bar' ⏏[…
19​:20 < FROGGS> r​: my $x = "['foo'|'bar']"; "lol foo bar" ~~ /<$x>/; say $/
19​:20 <+camelia> rakudo 211854​: OUTPUT«「foo」␤␤»
19​:20 < FROGGS> ahh
19​:20 < FROGGS> still weird

@p6rt
Copy link
Author

p6rt commented Jul 28, 2015

From @perlpilot

On Sat Jun 29 21​:37​:09 2013, jercos@​gmail.com wrote​:

From freenode's #perl6​:

19​:11 < jercos> r​: my $x = "'foo'|'bar'";("lol foo lol" ~~
/<$x>/).print
19​:11 <+camelia> rakudo 211854​: OUTPUT«foo»
19​:11 < jercos> r​: my $x = "'foo'|'bar'";("lol foo bar" ~~
/<$x>/).print
19​:11 <+camelia> rakudo 211854​: OUTPUT«lol»

Can not reproduce on recent rakudo​:

➤ perl6

my $x = "'foo'|'bar'";("lol foo bar" ~~ /<$x>/).say
「foo」
➤ perl6 --version
This is perl6 version 2015.07.1 built on MoarVM version 2015.07

19​:11 < jercos> :|
19​:12 < timotimo> a junction is not what you want in this case
19​:12 < timotimo> but try this​:
19​:12 < timotimo> er, i didn't see the " around it, sorry
19​:12 < timotimo> er, what is going on there? o_O
19​:17 < FROGGS> hmm
19​:17 < FROGGS> r​: my $x = "'foo'|'bar'";say "lol foo bar" ~~ /<$x>/
19​:17 <+camelia> rakudo 211854​: OUTPUT«「lol」␤␤»
19​:17 < FROGGS> r​: my $x = "'foo'|'bar'"; "lol foo bar" ~~ /<$x>/; say
$/
19​:17 <+camelia> rakudo 211854​: OUTPUT«「lol」␤␤»
19​:17 < FROGGS> r​: my $x = "'foo'|'bar'"; "lol foo bar" ~~ /<$x>/; say
$/.MATCH
19​:17 <+camelia> rakudo 211854​: OUTPUT«No such method 'MATCH' for
invocant of type 'Match'␤ in block at /tmp/yXMKPuD5qQ​:1␤␤»
19​:17 < FROGGS> err
19​:18 < FROGGS> r​: my $x = "'foo'|'bar'"; "lol foo bar" ~~ /(<$x>)/;
say $/.caps
19​:18 <+camelia> rakudo 211854​: OUTPUT«0 => Match.new(orig => "lol foo
bar", from => 0, to => 3, ast => Any, list => ().list, hash =>
EnumMap.new())␤»
19​:18 < FROGGS> r​: my $x = "'foo'|'bar'"; "loll foo bar" ~~ /(<$x>)/;
say $/.caps
19​:18 <+camelia> rakudo 211854​: OUTPUT«0 => Match.new(orig => "loll
foo bar", from => 0, to => 3, ast => Any, list => ().list, hash =>
EnumMap.new())␤»
19​:19 < FROGGS> r​: my $x = "'foo'"; "loll foo bar" ~~ /<$x>/; say $/
19​:19 <+camelia> rakudo 211854​: OUTPUT«「foo」␤␤»
19​:19 < FROGGS> r​: my $x = "'foo'"; "lol foo bar" ~~ /<$x>/; say $/
19​:19 <+camelia> rakudo 211854​: OUTPUT«「foo」␤␤»
19​:19 < FROGGS> r​: my $x = "'foo'||'bar'"; "lol foo bar" ~~ /<$x>/;
say $/
19​:19 <+camelia> rakudo 211854​: OUTPUT«「lol」␤␤»
19​:20 < FROGGS> r​: my $x = "'foo' ~ 'bar'"; "lol foo bar" ~~ /<$x>/;
say $/
19​:20 <+camelia> rakudo 211854​: OUTPUT«===SORRY!===␤Unrecognized regex
metacharacter ~ (must be quoted to match literally)␤at eval_0​:1␤------

my $x = anon regex { ^'foo' ~ 'bar' ⏏}␤Malformed regex␤at
eval_0​:1␤------> my $x = anon regex { ^'foo' ~ 'bar' ⏏[…
19​:20 < FROGGS> r​: my $x = "['foo'|'bar']"; "lol foo bar" ~~ /<$x>/;
say $/
19​:20 <+camelia> rakudo 211854​: OUTPUT«「foo」␤␤»
19​:20 < FROGGS> ahh
19​:20 < FROGGS> still weird

--

-Scott (PerlJam/perlpilot)

@p6rt p6rt closed this as completed Jul 28, 2015
@p6rt
Copy link
Author

p6rt commented Jul 28, 2015

@perlpilot - Status changed from 'new' to 'resolved'

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