nodejs / nodejs/cjs-module-lexer
Regexp/division after `]}` not properly disambiguated
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 262
- Forks
- 31
- Avg merge
- 9d 2h
- Merged PRs (30d)
- 5
Description
Consider these two inputs:
void {
x: []
} / "/ //" /*
/*/
module.exports.foo = 2;
// */
{
x: []
} / "/ //" /*
/*/
module.exports.foo = 2;
// */
In the first one it's an object divided by the string "/ //", followed by a comment and by the expression module.exports.foo = 2;.
In the second one it's a block containing a labeled statement (x: []), then there is a regular expression (/ "/), and inline comment and a block comment.
However, it returns exports: [ 'foo' ] for both the examples.
(Sorry for those /*//// */ patterns, but I need them to write "dual mode" code to toggle between code and comments 😅)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the two JavaScript inputs from the issue and comparing the lexer’s named-export result with the stated distinction between division and a regular expression. Then trace how the lexer handles ]} followed by /; done means the two examples are no longer treated identically.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100