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

Incorrect regular expression detection regarding break and continue #123

Closed
evanw opened this issue Jul 27, 2022 · 1 comment · Fixed by #124
Closed

Incorrect regular expression detection regarding break and continue #123

evanw opened this issue Jul 27, 2022 · 1 comment · Fixed by #124

Comments

@evanw
Copy link

evanw commented Jul 27, 2022

I was curious how regular expressions were handled and I noticed some cases with break and continue that aren't handled. Here's an example of one:

x: while (true) {
  if (foo) break
  /import("a")/.test(bar) || baz()
  if (foo) continue
  /import("b")/.test(bar) || baz()
  if (foo) break x
  /import("c")/.test(bar) || baz()
  if (foo) continue x
  /import("d")/.test(bar) || baz()
}

This library thinks that these are all imports.

@guybedford
Copy link
Owner

Thanks for posting. The lexer isn't perfect and there are some academic cases that can break it, in particular nodejs/cjs-module-lexer#22 and nodejs/cjs-module-lexer#20. We effectively do have a "real code" eventual cutoff which may not be the best choice for a perfect parser, although we do aim to support all real code. This is very much not an academic case though, fixed in #124.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants