[perl #127352] [BUG] Behavior of Regular Expressions Contained in a Constant with a Sigil
On Tue, 13 Mar 2018 14:50:17 -0700, jan-olof.hen...@bredband.net wrote: > On Fri, 05 Aug 2016 18:04:36 -0700, c...@zoffix.com wrote: > > Still present today: > > > > m: my $sepreg = rx/(<[\\/]>)/; my $filenameW = > > "c:\\g\\b.mp4"; $filenameW ~~ $sepreg; say $/; > > rakudo-moar 589061: OUTPUT«「\」 0 => 「\」» > > m: constant $sepreg = rx/(<[\\/]>)/; my $filenameW = > > "c:\\g\\b.mp4"; $filenameW ~~ $sepreg; say $/; > > rakudo-moar 589061: OUTPUT«Nil» > > m: constant sepreg = rx/(<[\\/]>)/; my $filenameW = > > "c:\\g\\b.mp4"; $filenameW ~~ sepreg; say $/; > > rakudo-moar 589061: OUTPUT«「\」 0 => 「\」» > > Fixed with commit > https://github.com/rakudo/rakudo/commit/5ac593ee098f204ea69ef57edd9ae0925c544ea4 Roast test added with commit https://github.com/perl6/roast/commit/f2d422f229f50b14f47d803362c7af8e73b8c13b
[perl #127352] [BUG] Behavior of Regular Expressions Contained in a Constant with a Sigil
On Fri, 05 Aug 2016 18:04:36 -0700, c...@zoffix.com wrote: > Still present today: > > m: my $sepreg = rx/(<[\\/]>)/; my $filenameW = > "c:\\g\\b.mp4"; $filenameW ~~ $sepreg; say $/; > rakudo-moar 589061: OUTPUT«「\」 0 => 「\」» > m: constant $sepreg = rx/(<[\\/]>)/; my $filenameW = > "c:\\g\\b.mp4"; $filenameW ~~ $sepreg; say $/; > rakudo-moar 589061: OUTPUT«Nil» > m: constant sepreg = rx/(<[\\/]>)/; my $filenameW = > "c:\\g\\b.mp4"; $filenameW ~~ sepreg; say $/; > rakudo-moar 589061: OUTPUT«「\」 0 => 「\」» Fixed with commit https://github.com/rakudo/rakudo/commit/5ac593ee098f204ea69ef57edd9ae0925c544ea4
[perl #127352] [BUG] Behavior of Regular Expressions Contained in a Constant with a Sigil
# New Ticket Created by Joseph Polanik # Please include the string: [perl #127352] # in the subject line of all future correspondence about this issue. # https://rt.perl.org/Ticket/Display.html?id=127352 > Constants are not required to have a sigil but apparently they may. Unfortunately, when a constant with a sigil contains a regex pattern, unpredictable results may occur. The attached file show that a regex pattern that should detect the file system separator ('/' or '\') yield incorrect results when contained in a constant whose names contains a sigil but correct results otherwise. Identical results were obtained on Linux (Ubuntu 12.04) and Mac OS X 10.10.5 Build information Linux $ perl6 -version This is Rakudo version 2015.12 built on MoarVM version 2015.12 implementing Perl 6.c. Mac $ perl6 -version This is Rakudo version 2015.12-176-gaefe2c2 built on MoarVM version 2015.12-29-g8079ca5 implementing Perl 6.c. Thanks, Joseph Polanik #!/usr/bin/env perl6 # Constants are not required to have a sigil. When they have a sigil and # contain a regex, the results are unpredictable. constant $sepreg = /(<[\\\/]>)/; my $sepreg2 = /(<[\\\/]>)/; constant sepreg3 = /(<[\\\/]>)/; my $filenameW = "c:\\g\\b.mp4"; my $filenameL = "/g/b.mp4"; say "= Looking for a Windows separator: \\"; # The match is made but $/ doesn't get populated say "Testing regex as a constant with a sigil: Windows separator"; if ($filenameW ~~ $sepreg) { say $/[0].Str; } else { say "No match for SEP"; } # Gives correct result say "Testing regex as a constant with no sigil: Windows separator"; if ($filenameW ~~ sepreg3) { say $/[0].Str; } else { say "No match for SEP"; } # Gives correct result say "Testing regex as a lexical variable: Windows separator"; if ($filenameW ~~ $sepreg2) { say $/[0].Str; } else { say "No match for SEP"; } # Gives correct result say "Testing regex as a string: Windows separator"; if ($filenameW ~~ /(<[\\\/]>)/) { say $/[0].Str; } # # Now try the same tests with a *nix file system # say "= Looking for a *nix separator: /"; # The match is made but $/ doesn't get populated say "Testing regex as a constant with a sigil: *nix separator: Wrong Result"; if ($filenameL ~~ $sepreg) { say $/[0].Str; } else { say "No match for SEP"; } # Gives correct result say "Testing regex as a constant with no sigil: *nix separator"; if ($filenameL ~~ sepreg3) { say $/[0].Str; } else { say "No match for SEP"; } # Gives correct result say "Testing regex as a lexical variable: *nix separator"; if ($filenameL ~~ $sepreg2) { say $/[0].Str; } else { say "No match for SEP"; } # Gives correct result say "Testing regex as a string: *nix separator"; if ($filenameL ~~ /(<[\\\/]>)/) { say $/[0].Str; }