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

escodegen expects value in Property key:value pair to have a type; crashes on null #461

Open
KevinCarhart opened this issue Dec 18, 2023 · 0 comments

Comments

@KevinCarhart
Copy link

KevinCarhart commented Dec 18, 2023

Hello
Thank you for the project. We have used it for many years on the edbrowse project, a CLI web browser. We use esprima-next and escodegen in succession in order to deminify a wide variety of JS files from the internet at large.

escodegen is crashing on an esprima-next AST built from https://goodcleanhumor.com/_next/static/chunks/502-b51afe70c57c9f6e.js

from the site goodcleanhumor.com


Here is a more concise piece of JS to recreate the problem:
hey = esprima.parse('class tb extends Error{sys;details}')
escodegen.generate(hey)


Here is the runtime error text and the end of the stack trace. It is called from Property. The portion that resolves the key ("sys") succeeds, and then it crashes in the portion that resolves the value.

(the line numbers won't align because we combine esprima and escodegen in one file)

jdb line 9187: TypeError: cannot read property 'type' of null
at (demin.js:9187)
at Property (demin.js:8928)
at (demin.js:9191)
at (demin.js:8075)
at withIndent (demin.js:7601)
at ClassBody (demin.js:8080)
at (demin.js:9199)
at ClassDeclaration (demin.js:8099)


Here is the result of JSON.stringify of the AST that we are running generate on. So that I'm not giving you an example that requires running esprima first in order to recreate.

{"type":"Program","body":[{"type":"ClassDeclaration","id":{"type":"Identifier","name":"tb"},"superClass":{"type":"Identifier","name":"Error"},"body":{"type":"ClassBody","body":[{"type":"Property","key":{"type":"Identifier","name":"sys"},"computed":false,"value":null,"static":false,"decorators":null},{"type":"Property","key":{"type":"Identifier","name":"details"},"computed":false,"value":null,"static":false,"decorators":null}]},"decorators":null}],"sourceType":"script"}

thank you
Kevin Carhart

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

1 participant