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

JS/TS detect all syntax errors in RegExps. #48933

Closed
pygy opened this issue May 3, 2022 · 3 comments
Closed

JS/TS detect all syntax errors in RegExps. #48933

pygy opened this issue May 3, 2022 · 3 comments
Labels
Duplicate An existing issue was already created

Comments

@pygy
Copy link

pygy commented May 3, 2022

VSCode detects some syntax errors in RegExps in JS (e.g. /[/ gets squiggles and a helpful message on hover), but it misses many others

As you know, in JS (And thus TS), Unicode regexps have a grammar that's incompatible with legacy, non-u ones, and it should be taken into account.

All of these are invalid, but are not marked as such:

/\b+/ // can't quantify assertions
/^+/ // can't quantify assertions
/$+/ // can't quantify assertions
/(?<=)+/ // can't quantify assertions
/(?=)+/u // can't quantify look ahead assertions in u mode
/]/u // syntax characters must be escaped in u mode
/{a}/u // syntax characters must be escaped in u mode
/\-/u // non-syntax characters must not be escaped in u mode
/\1/u // orphan back reference in u mode
/\k<OrphanNameRefWithUFlag>/u
@pygy
Copy link
Author

pygy commented May 3, 2022

As mentioned in microsoft/vscode#148612, I'm working on a RegExp tokenizer that may be useful to implement this.

@mjbvz mjbvz transferred this issue from microsoft/vscode May 3, 2022
@mjbvz mjbvz removed their assignment May 3, 2022
@andrewbranch
Copy link
Member

Duplicate of #3432

@andrewbranch andrewbranch marked this as a duplicate of #3432 May 3, 2022
@andrewbranch andrewbranch added the Duplicate An existing issue was already created label May 3, 2022
@typescript-bot
Copy link
Collaborator

This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

4 participants