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

Should be using the directive estree field #440

Open
lachrist opened this issue Jan 8, 2021 · 0 comments
Open

Should be using the directive estree field #440

lachrist opened this issue Jan 8, 2021 · 0 comments

Comments

@lachrist
Copy link

lachrist commented Jan 8, 2021

There is a field in the entree spec which saves the raw value of directives: https://github.com/estree/estree/blob/master/es5.md#directive
Because escodegen does not use this field, it transform invalid use-strict directives into valid ones:

const code1 = "'use\\u0020strict';";
const estree1 = require("acorn").parse(code1, {ecmaVersion:2020});
const code2 = require("escodegen").generate(estree1);
console.log(code2) // prints "'use strict';" instead of "'use\\u0020strict';"

There exists some test262s which account for that:

https://github.com/tc39/test262/blob/main/test/language/directive-prologue/14.1-5-s.js
https://github.com/tc39/test262/blob/main/test/language/directive-prologue/14.1-4-s.js

Kind regards,
Laurent

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