-
-
Notifications
You must be signed in to change notification settings - Fork 22
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
Tests fail when SES is used #79
Comments
I'm also seeing issues in es-abstract where the main entry point is returning a non-extensible object. |
so i see this
but its coming from |
|
for the issue is related to Reflect.getOwnPropertyDescriptor(Function.prototype, 'apply')
// no ses:
// --> { value: apply () { ... } }
// with ses
// --> { get: getApply () { ... } } |
I’m seeing that error even with the patched version of object.assign :-/ Does that mean that SES replaces intrinsic data property methods with getters?? The spec requires they be data properties. |
yes, though i think its mostly just to make it read-only. doesnt seem like a requirement.
oh really? could you provide a reference for that? ill bring it up at the next ses-lavamoat call |
i mean, everything that doesn't have a |
I see, this get/set pattern is the overwrite mistake workaround |
I'm not sure what the fix can really be here. I suppose I could try to detect SES, but it seems pretty bad to have I'm a bit confused tho - the "overwrite mistake" is how the spec works, right? What if there's code relying on it? |
This fix for the override mistake is used by Agoric, Salesforce, MetaMask, Node, Google, Bloomberg and others. AFAIK, none of us have run into a single example of code we wanted to run that relies on the override mistake throwing an exception. However, my impression is that tc39/ecma262#1320 (comment) -- the proposal to fix the override mistake pervasively and unconditionally --- did run into some compat problem. In any case, the total amount of code broken by that will be negligible compared to the code broken by freezing the primordials. |
However, the concern you raise --- code broken not by the absence of override-mistake behavior, but rather, caused by changing these properties from data to accessor, is a different matter. I would like to understand better the problem you're running into. Can you state a self-contained explanation of why and how your code is hitting this? Thanks. |
I certainly can understand making that tradeoff decision within SES - but it leaves me in a position where some of my packages are incompatible with SES, and also, all of my packages's tests are likely incompatible with SES. Do you have a suggestion that wouldn't involve either a) hardcoding all expected data properties (or, all expected accessors), or b) hardcoding assumptions about SES? |
Before making suggestions, I'd like to understand the problem first. Self contained explanation please? |
Sure! I have a When I do, for example, |
Why does invoking the accessor's getter throw an error? The getter of the accessors created by this repair return the original value. Can we try a simple example to demonstrate the problem? When your code calls the accessor's getter, what this-binding does it provide? If it provides an object for which |
Scratch that. The getter itself should work independent of |
The relevant getter is defined at function getter() {
return value;
} That's it. |
Where is your |
Trying to narrow this down: Boolean.prototype.valueOf.call(require('es-abstract/helpers/callBind').apply(Object.assign)(Object, [true])); this passes without lockdown, fails with it. Boolean.prototype.valueOf.call(Reflect.apply(Function.bind, Function.apply, [Object.assign])(Object, [true])); passes on both, as does: Boolean.prototype.valueOf.call(Reflect.apply(require('function-bind'), Function.prototype.apply, [Object.assign])(Object, [true])); |
https://github.com/ljharb/es-abstract/blob/HEAD/GetIntrinsic.js#L266 is the GetIntrinsic line. |
At #79 (comment) you said
But, as @kumavis commented earlier, you're not calling the getter. You're using the getter function itself as the value. That can never be correct. Try value = isOwn ? desc.get() || desc.value : value[part]; which is an adequate fix for SES, but is not correct in general because it doesn't give the getter the proper |
OK, this code fails with SES but passes otherwise: var { assign } = Object;
var apply = GetIntrinsic('%Function.prototype.apply%');
Boolean.prototype.valueOf.call(Reflect.apply(Function.prototype.bind, apply, [assign])(Object, [true])); In other words, |
Why isn't this line simply value = value[part]; Under what circumstances does this misbehave? |
In other words, I misspoke. es-abstract is NOT reifying the getter, which means that when you convert a data property to an accessor, i suddenly start getting a getter function instead of the real function. |
That's a bug. What you said earlier is what it should do. Yes? Once fixed --- see my suggested replacements above --- does everything work? |
My code replacement at #79 (comment) is incorrect because it uses the result of the call to the left of the |
It's not a bug, it's how it works by design. The intended use is to get getters as functions, so they can be In other words, I'm trying to get the getter when the spec says it's a getter and the value when the spec says it's a data property. |
This special case for the getter seems weird. How do you name the setter?
|
There are no spec-provided setters I'm aware of besides |
Fixes ljharb/object.assign#79 ``` // Detect when the getter of an accessor // alleges that it was originally a data property which value is // the value of the property named by this symbol. This enables a // leaky and cooperative partial emulation of the original data property, // as code such as this uses this property to uphold the illusion. // See ljharb/object.assign#79 and // endojs/endo#473 (comment) // // TODO Jordan, I don't know what version of JS this is supposed to run on. // But it looks like it is one that does not yet support Symbol.for. // I can take Kris' advice at // endojs/endo#473 (review) // and revise SES again to make this a string-named property. What do you suggest? ```
If https://github.com/ljharb/object.assign/blob/main/test/ses-compat.js#L15 is changed to
require('.')
, so it runs the tests:Boolean.prototype.valueOf.call(require('.')(true))
fails (althoBoolean.prototype.valueOf.call(Object.assign(true))
still succeeds).cc @kumavis
We need to figure out if this is a bug in the entry point, or a bug in SES.
The text was updated successfully, but these errors were encountered: