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

runtime - class inheritance pattern not compatible with frozen intrinsics #410

Closed
kumavis opened this issue Mar 22, 2021 · 1 comment · Fixed by #411
Closed

runtime - class inheritance pattern not compatible with frozen intrinsics #410

kumavis opened this issue Mar 22, 2021 · 1 comment · Fixed by #411

Comments

@kumavis
Copy link
Contributor

kumavis commented Mar 22, 2021

it is becoming increasingly common to freeze javascript intrinsics (Object, Array...) (see nodejs, endo/ses, xs)

while this is generally not an issue for packages that do not extend intrinsics, there are a few unfortunate side effects due to javascript's "override mistake", namely obj.constructor = ... fails due to the inherited property "constructor" being read-only on Object.prototype

here is the inheritance pattern at fault

GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
GeneratorFunctionPrototype.constructor = GeneratorFunction;

here is a compatible inheritance pattern
https://github.com/isaacs/inherits/blob/9a2c29400c6d491e0b7beefe0c32efa3b462545d/inherits_browser.js#L6-L13
alternatively you can just use defineProperty instead of assignment

reproduction steps:

Object.freeze(Object.prototype)
require('./runtime.js')
@kumavis kumavis changed the title class inheritance pattern not compatible with frozen intrinsics runtime - class inheritance pattern not compatible with frozen intrinsics Mar 22, 2021
@kumavis
Copy link
Contributor Author

kumavis commented Mar 24, 2021

fix is ready here ---> #411

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

Successfully merging a pull request may close this issue.

1 participant