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

CreateDataProperty is sometimes called with ? but can't throw #703

Closed
jyasskin opened this issue Sep 29, 2016 · 10 comments
Closed

CreateDataProperty is sometimes called with ? but can't throw #703

jyasskin opened this issue Sep 29, 2016 · 10 comments
Labels
completion records Relates to completion records, and ? / ! notation.

Comments

@jyasskin
Copy link

https://tc39.github.io/ecma262/#sec-internalizejsonproperty, https://tc39.github.io/ecma262/#sec-createdatapropertyorthrow, and a few other places use "? CreateDataProperty(...)", but its definition appears to use just true and false return values to say whether it has succeeded.

This is related to #253.

@shvaikalesh
Copy link
Member

shvaikalesh commented Sep 29, 2016

O may be an exotic Proxy object with defineProperty trap that throws or breaks invariants. Please, see [[DefineOwnProperty]].

@jyasskin
Copy link
Author

In that case, the far more common use of CreateDataProperty() without either ! or ? should be fixed.

@shvaikalesh
Copy link
Member

shvaikalesh commented Sep 29, 2016

I have checked all (49) usages of CreateDataProperty and there are no calls without ! or ? that may receive Proxy as first argument.

@ljharb
Copy link
Member

ljharb commented Sep 29, 2016

@shvaikalesh any user-provided object, including "this" values, could be a Proxy.

@shvaikalesh
Copy link
Member

shvaikalesh commented Sep 29, 2016

All ! / ?-less calls operate on objects created in the same abstract operation or method, mostly arrays or plain objects. They do not get any user-passed stuff.

@shvaikalesh
Copy link
Member

may receive Proxy as first argument.

sorry for the confusion, I meant first argument of CreateDataProperty

@ljharb
Copy link
Member

ljharb commented Sep 29, 2016

Does the HTML spec use that abstract operation at all?

@annevk
Copy link
Member

annevk commented Sep 30, 2016

@ljharb it does at the end of https://html.spec.whatwg.org/multipage/infrastructure.html#structuredclone preceded by ?. Although I think in HTML's case it cannot really be called on a proxy so maybe that is wrong?

@ljharb ljharb added the completion records Relates to completion records, and ? / ! notation. label Mar 21, 2018
@ljharb
Copy link
Member

ljharb commented Jan 3, 2020

There are currently 4 remaining uses of ? with CreateDataProperty in the spec:

  • 1 in CreateDataPropertyOrThrow (this is fine)
  • 2 in InternalizeJSONProperty, which are intentional and noted as such explicitly
  • 1 in OrdinarySetWithOwnDescriptor

Since [[DefineOwnProperty]] could throw, the ? on CreateDataProperty seems correct to me - but I could easily be wrong here. As I see it, this issue should be closed with one of two outcomes:

  1. Removal of the ? on the [[DefineOwnProperty]] call inside CreateDataProperty, with an accompanying assertion that O must be an ordinary object (or whatever assertion is applicable to ensure it can't throw), and then removal of the ? on all CreateDataProperty calls
  2. No further change is needed.

I'm going to close it assuming the latter; but will happily reopen it if needed.

@ljharb ljharb closed this as completed Jan 3, 2020
@annevk
Copy link
Member

annevk commented Jan 3, 2020

HTML seems to have changed to use ! meanwhile, FWIW.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
completion records Relates to completion records, and ? / ! notation.
Projects
None yet
Development

No branches or pull requests

4 participants