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

Array.from should not touch Array.prototype setters (createDataPropertyOrThrow) #415

Closed
Yaffle opened this issue Mar 24, 2016 · 7 comments
Closed
Assignees

Comments

@Yaffle
Copy link
Contributor

Yaffle commented Mar 24, 2016

An edge case...

Object.defineProperty(Object.prototype, "0", {
  set: function () {
    throw new Error();
  },
  get: function () {
    return undefined;
  }
});

Array.from({length: 1}); // should not throw here

@Yaffle Yaffle changed the title Array.from should not touch Array.from should not touch Array.prototype setters Mar 24, 2016
@Yaffle Yaffle changed the title Array.from should not touch Array.prototype setters Array.from should not touch Array.prototype setters (createDataPropertyOrThrow) Mar 24, 2016
@Yaffle
Copy link
Contributor Author

Yaffle commented Mar 24, 2016

Ah... this was fixed in https://github.com/mathiasbynens/Array.from ... sorry

@Yaffle Yaffle closed this as completed Mar 24, 2016
@ljharb
Copy link
Collaborator

ljharb commented Mar 24, 2016

Hmm, there's no fix for this in https://github.com/mathiasbynens/Array.from or this repo at all?

However, according to https://tc39.github.io/ecma262/#sec-array.from step 12.b., it seems like it should indeed throw in this case.

@Yaffle
Copy link
Contributor Author

Yaffle commented Mar 24, 2016

What about step 12.e ?

@ljharb
Copy link
Collaborator

ljharb commented Mar 24, 2016

Ah, you're correct that step 12e is what applies here - but the ? in the spec means if CreateDataPropertyOrThrow returns an abrupt completion, that the exception should be thrown.

@Yaffle
Copy link
Contributor Author

Yaffle commented Mar 24, 2016

OK

@Yaffle
Copy link
Contributor Author

Yaffle commented Mar 25, 2016

@ljharb The setter will not be touched with CreateDataPropertyOrThrow.

@ljharb
Copy link
Collaborator

ljharb commented Mar 25, 2016

Good call, you're totally correct. Thanks for clarifying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants