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

Escaped hash character \# is somtimes parsed incorrectly #6654

Closed
p6rt opened this issue Dec 29, 2017 · 5 comments
Closed

Escaped hash character \# is somtimes parsed incorrectly #6654

p6rt opened this issue Dec 29, 2017 · 5 comments
Labels
parser regex Regular expressions, pattern matching, user-defined grammars, tokens and rules

Comments

@p6rt
Copy link

p6rt commented Dec 29, 2017

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

Searchable as RT132666$

@p6rt
Copy link
Author

p6rt commented Dec 29, 2017

From @smls

These regexes parse and run fine (they match a single `#` character)​:

  /\#/;
  /^\#/;

But this one doesn't​:

  /^ \#/;

The error thrown, is​:

  ===SORRY!===
  Regex not terminated.
  at -e​:1
  ------> /^ \#/⏏<EOL>
  Unable to parse regex; couldn't find final '/'
  at -e​:1
  ------> /^ \#/⏏<EOL>
  expecting any of​:
  infix stopper

It's as if the parser fails to recognize that the `#` character was
escaped (interpreting the backslash as unspace maybe?), and treats
everything until the end of the line as a comment.

This seems to be only happening when the escaped `#` character is
preceded by another token, *and* separated from it by whitespace.

Apparently this bug has always existed in Rakudo​:
https://gist.github.com/Whateverable/ca082a33d2ab689bf3ca4b6f7ae2d19f

@p6rt
Copy link
Author

p6rt commented Dec 29, 2017

From @zoffixznet

On Fri, 29 Dec 2017 07​:05​:29 -0800, smls75@​gmail.com wrote​:

These regexes parse and run fine (they match a single `#` character)​:

/\\\#/;
/^\\\#/;

But this one doesn't​:

/^ \\\#/;

The error thrown, is​:

===SORRY\!===
Regex not terminated\.
at \-e&#8203;:1
\-\-\-\-\-\-> /^ \\\#/⏏\<EOL>
Unable to parse regex; couldn't find final '/'
at \-e&#8203;:1
\-\-\-\-\-\-> /^ \\\#/⏏\<EOL>
    expecting any of&#8203;:
        infix stopper

It's as if the parser fails to recognize that the `#` character was
escaped (interpreting the backslash as unspace maybe?), and treats
everything until the end of the line as a comment.

This seems to be only happening when the escaped `#` character is
preceded by another token, *and* separated from it by whitespace.

Apparently this bug has always existed in Rakudo​:
https://gist.github.com/Whateverable/ca082a33d2ab689bf3ca4b6f7ae2d19f

Thank you for the report. This is a duplicate of rakudo/rakudo#1324

The problematic cases are matched[^1] as unspaces. The `\#` thing was never meant[^2] to work, but it slipped through and now we probably have to deal with back-compat issues in order to fix it.

[1] rakudo/rakudo#1324 (comment)
[2] rakudo/rakudo#1324 (comment)

@p6rt
Copy link
Author

p6rt commented Dec 29, 2017

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

@p6rt p6rt closed this as completed Dec 29, 2017
@p6rt
Copy link
Author

p6rt commented Dec 29, 2017

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

@p6rt p6rt added parser regex Regular expressions, pattern matching, user-defined grammars, tokens and rules labels Jan 5, 2020
@JJ
Copy link

JJ commented Jun 28, 2020

I'm not sure about reopening this, but the error still seems to be there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
parser regex Regular expressions, pattern matching, user-defined grammars, tokens and rules
Projects
None yet
Development

No branches or pull requests

2 participants