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

Forbid \b (backspace) escape sequence in regexes to catch a P5-ism #5592

Closed
p6rt opened this issue Aug 18, 2016 · 8 comments
Closed

Forbid \b (backspace) escape sequence in regexes to catch a P5-ism #5592

p6rt opened this issue Aug 18, 2016 · 8 comments
Labels
NYI Features not yet implemented

Comments

@p6rt
Copy link

p6rt commented Aug 18, 2016

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

Searchable as RT128986$

@p6rt
Copy link
Author

p6rt commented Aug 18, 2016

From @smls

S05 <http://design.perl6.org/S05.html#line_2234> says​:

  Backslash escapes for literal characters in ordinary strings are
  allowed in regexes (\a, \x, etc.). However, the exception to this
  rule is \b, which is disallowed in order to avoid conflict with
  its former use as a word boundary assertion. To match a literal
  backspace, use \c8, \x8, or a double-quoted \b.

I found out the hard way today why that second sentence was specced, when I puzzled over a regex of mine for several minutes before I realized that the reason it didn't match, was that I had written my word boundaries as `\b` (Perl/GNU/.NET regex syntax) instead of `<|w>` (Perl 6 regex syntax).

@p6rt
Copy link
Author

p6rt commented Aug 24, 2016

From @zoffixznet

+1

This can't be added in 6.c, however.

@p6rt
Copy link
Author

p6rt commented Aug 24, 2016

From @zoffixznet

Listed self as steakholder to implement this in 6.d​: Raku/old-design-docs@b14828bb01

@p6rt
Copy link
Author

p6rt commented Aug 25, 2016

From @pmichaud

I don't quite understand what is meant by "This can't be added in 6.c, however" above.

If it's intended to mean "We can't add this to the 6.c language spec" (because it was released in December), then I pretty much agree with that.

But if it's intended to mean "We can't change this behavior in Rakudo until we update the spec", I disagree.

The 6.c spec (what is in roast) doesn't appear to have any tests for \b in regexes, which (to me) means the behavior of \b is undefined (or undertested) in 6.c. I don't think it should mean that Rakudo's current behavior is the 6.c behavior.

Furthermore, given that S05 has (for a couple of years) already explicitly called out \b as being forbidden, this looks to me like a run-of-the-mill rakudobug that simply needs a corrected implementation and corresponding tests added to roast. And adding the tests into roast will automatically makes it part of the 6.d spec.

Or am I missing something entirely?

Pm

On Wed Aug 24 11​:04​:41 2016, cpan@​zoffix.com wrote​:

Listed self as steakholder to implement this in 6.d​:
Raku/old-design-docs@b14828bb01

@p6rt
Copy link
Author

p6rt commented Aug 25, 2016

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

@p6rt
Copy link
Author

p6rt commented Aug 25, 2016

From @zoffixznet

Per comments on [^1], this ticket can be resolved right now, without waiting for 6.d

[1] Raku/old-design-docs@b14828b#commitcomment-18777938

@p6rt
Copy link
Author

p6rt commented Dec 4, 2016

From @zoffixznet

On Thu, 18 Aug 2016 10​:27​:04 -0700, smls75@​gmail.com wrote​:

S05 <http://design.perl6.org/S05.html#line_2234> says​:

Backslash escapes for literal characters in ordinary strings are
allowed in regexes (\a, \x, etc.). However, the exception to this
rule is \b, which is disallowed in order to avoid conflict with
its former use as a word boundary assertion. To match a literal
backspace, use \c8, \x8, or a double-quoted \b.

I found out the hard way today why that second sentence was specced,
when I puzzled over a regex of mine for several minutes before I
realized that the reason it didn't match, was that I had written my
word boundaries as `\b` (Perl/GNU/.NET regex syntax) instead of `<|w>`
(Perl 6 regex syntax).

Thanks for the report. This is now fixed \o/

Fix commits​:
Raku/nqp@c5f38888ec
Raku/nqp@66308ea63d
rakudo/rakudo@08589d32fa

Tests​: Raku/roast@846af2a582

@p6rt
Copy link
Author

p6rt commented Dec 4, 2016

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

@p6rt p6rt closed this as completed Dec 4, 2016
@p6rt p6rt added the NYI Features not yet implemented label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NYI Features not yet implemented
Projects
None yet
Development

No branches or pull requests

1 participant