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

Crash on optional chaining #110

Closed
mysticatea opened this issue Jun 17, 2020 · 3 comments
Closed

Crash on optional chaining #110

mysticatea opened this issue Jun 17, 2020 · 3 comments

Comments

@mysticatea
Copy link
Contributor

Some queries crash on optional chaining.

Repro code:

  • Node 12.12.0
  • acorn@7.3.1
  • esquery@1.3.1
const acorn = require("acorn")
const esquery = require("esquery")

const ast = acorn.parse("a?.b", { ecmaVersion: 2020 })
console.log(esquery(ast, ":nth-child(1)"))

Error:

TypeError: Cannot read property 'length' of undefined
    at f (C:\Users\t-nagashima.AD\dev\sandbox\node_modules\esquery\dist\esquery.min.js:1:32431)
    at l (C:\Users\t-nagashima.AD\dev\sandbox\node_modules\esquery\dist\esquery.min.js:1:30995)
    at f.enter (C:\Users\t-nagashima.AD\dev\sandbox\node_modules\esquery\dist\esquery.min.js:1:32935)
    at f.__execute (C:\Users\t-nagashima.AD\dev\sandbox\node_modules\esquery\dist\esquery.min.js:1:8604)
    at f.traverse (C:\Users\t-nagashima.AD\dev\sandbox\node_modules\esquery\dist\esquery.min.js:1:9487)
    at Object.y [as traverse] (C:\Users\t-nagashima.AD\dev\sandbox\node_modules\esquery\dist\esquery.min.js:1:2490)
    at h (C:\Users\t-nagashima.AD\dev\sandbox\node_modules\esquery\dist\esquery.min.js:1:32878)
    at d (C:\Users\t-nagashima.AD\dev\sandbox\node_modules\esquery\dist\esquery.min.js:1:33189)
    at m (C:\Users\t-nagashima.AD\dev\sandbox\node_modules\esquery\dist\esquery.min.js:1:33278)
@brettz9
Copy link
Contributor

brettz9 commented Jun 18, 2020

I've asked @michaelficarra at #67 (comment) whether we might provide a method to supply a custom traverser or VisitorKeys (to support such more recent syntaxes) but pending such a decision, and as also mentioned there, #105 added a lite build which should at least allow overriding the traverser version in use.

FWIW, estools/estraverse#112 was filed on the estraverse side, so if support gets added there, this particular feature at least may become available anyways (at least with a version bump if needed).

@brettz9
Copy link
Contributor

brettz9 commented Feb 5, 2021

I believe this can now be closed.

@michaelficarra
Copy link
Member

Fixed by #112.

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

No branches or pull requests

3 participants