Skip to content

Export not detected #20

Open
Open

Description

@nicolo-ribaudo

⚠️ This is not real-world code. It's technically a bug, but no real program will notice it. Feel free to close this issue!

Consider this non-strict mode code: (GitHub's syntax highlighting is broken)

function fn() {
    yield / "/ //" /*
}
/*/
}

module.exports.foo = 2;

// */

The tokens are:

[function] [Identifier: fn] [paren left] [paren left] [brace left]
[Identifier: yield] [division] [String: "/ //"] [Comment: \n}\n/ ]
[brace right]

[Identifier: module] [dot] [Identifier: exports] [dot] [Identifier: foo] [equal] [Number: 2] [semicolon]

However, cjs-module-lexer returns { exports: [], reexports: [] }.

Activity

  1. guybedford commented on Oct 28, 2020

    @guybedford
    Collaborator

    Improving the lexing ambiguity cases is always a goal so thanks for posting, but yes there isn't a rush to fix this :)

    I wasn't aware the this would be parsed as division in this expression position... what is it that makes yield act differently to return here?

  2. guybedford commented on Oct 28, 2020

    @guybedford
    Collaborator

    I've posted a potential fix in #21, interestingly it's a negative diff and thankfully doesn't require any extra work :)

    Would be grateful if you could review when you can.

  3. changed the title [-]Export not detected (edge case)[/-] [+]Export not detected[/+] on Dec 10, 2023
  4. added
    bugSomething isn't working
    and removed on Dec 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions