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
Problems with regexp literals in JS #2154
Comments
Yet another bug I just found:
When a regexp literal is preceded by a closing parenthesis, the script parses it as a division operator. |
Thanks for reporting! I fixed the first two examples in #2158, but the We could try to parse the expression but this will be hard because recursive expressions are CF but we can try to approximate with a little effort and check as to whether the token before the expression is a statement keyword like // the lookbehind is to ensure that we don't have a function name (e.g. foo_if() )
/(?<![$\w ...other chars])(?:if|for|while|...)\s*\((?:<comments>|<strings>|<other>|\(<recursive part>\))*\)\s*<regex>/ So it's approximately possible (we can only match a finite number of nested parentheses) it will also cause the regex pattern to be a long slower than it has to be just for one rare edge case. I'll close the issue because as explained the first two issues will be resolved soon and the last one isn't worth it for just syntax highlighting. |
In Javascript, regexp literals followed by any operator or comment, are not highlighted properly. Try these:
let a = /regex/ // comment
let b = condition ? /regex/ : /another one/
The text was updated successfully, but these errors were encountered: