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

[DEGRADE] Object.assign polyfill isn't injected by ES2018 object rest props #3139

Closed
teppeis opened this issue Nov 6, 2018 · 5 comments
Closed
Labels
internal-issue-created An internal Google issue has been created to track this GitHub issue P2 triage-done Has been reviewed by someone on triage rotation.

Comments

@teppeis
Copy link
Contributor

teppeis commented Nov 6, 2018

Input:

module.exports = () => {
  var {a, ...rest} = {a: 1, b: 2, c: 3};
  return a === 1 && rest.a === undefined && rest.b === 2 && rest.c === 3;
};

v20181008 injects Object.assign polyfill expectdly: output

v20181028 doesn't: output

In result, the compiled code throws TypeError: Object function Object() { [native code] } has no method 'assign'.

@brad4d
Copy link
Contributor

brad4d commented Nov 7, 2018

I believe this is due to the transpilation of destructuring being moved after all checks, which includes it moving after the pass that injects polyfills.
It will be fixed automatically when we make the planned change to have the polyfills pass always inject all polyfills required by the difference between the input and output language modes, but that also requires changes to RemoveUnusedCode so it can safely remove the polyfills that aren't actually needed.

We should be able to fix this more quickly than that by changing the es6InjectRuntimeLibraries pass to explicitly inject the Object.assign polyfill.

@brad4d
Copy link
Contributor

brad4d commented Nov 7, 2018

Internal Google bug created: b/119199280

@teppeis
Copy link
Contributor Author

teppeis commented Feb 21, 2019

From v20190121, Object.assign is not injected for object spread properties too.

@lauraharker lauraharker added internal-issue-created An internal Google issue has been created to track this GitHub issue triage-done Has been reviewed by someone on triage rotation. labels Feb 22, 2019
@teppeis
Copy link
Contributor Author

teppeis commented Nov 17, 2019

Not yet fixed in v20191111: input / output

@teppeis
Copy link
Contributor Author

teppeis commented Sep 2, 2021

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal-issue-created An internal Google issue has been created to track this GitHub issue P2 triage-done Has been reviewed by someone on triage rotation.
Projects
None yet
Development

No branches or pull requests

3 participants