-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Normative: Re-resolve unresolvable references on the global in PutValue. #2205
base: main
Are you sure you want to change the base?
Conversation
Currently, JSC, V8, SM, and XS all *do not throw* on the following code, contra spec: ```javascript "use strict"; undeclared = (this.undeclared = 42); ``` This has been a bug in implementations for a decade (https://bugzilla.mozilla.org/show_bug.cgi?id=605515), and is arguably implementation reality not only for the web but for most implementations. This changes the spec to match the implemented re-resolution behavior. Also see - tc39#467 - tc39/test262#1964
I’d prefer if this were Annex B‑only, since the |
Would it make you feel better if the example code was |
I agree but we have |
This needs more investigation. @erights brought up in plenary that we should prefer late resolution over re-resolution, even if the observability point is [[HasProperty]], which I agree with. Further, we should endeavor to have consistent late resolution behavior across For foo = "global";
let scopeObj = { };
with (scopeObj) {
foo = (scopeObj.foo = "with1", "with2");
}
print(scopeObj.foo);
print(globalThis.foo); Currently engines disagree:
|
For the global lexical environment, I haven't crafted this yet but it should be possible to do so by injecting a |
3d0c24c
to
7a79833
Compare
It seems like the foo = 1;
var resolve;
new Promise((r) => { resolve = r }).then(() => {
foo = (globalThis.foo = 3, 4);
console.log(foo, globalThis.foo);
});
document.write(`<script>let foo = 2; resolve();</script>`); Safari, Chrome, and FF all print 4 and 3 here. |
@rkirsling I’m not 100% sure but I thought @syg was describing a scenario where a lexical binding can become declared during RHS eval where the LHS was unresolvable (not a global object env binding interaction) — i.e. ScriptEvaluation being entered in the RHS via document.write. |
A test for global lexical bindings (i.e. converting @bathos's words to code): let foo2 = foo = (document.write(`<script>let foo = 2</script>`), 4);
console.log(foo, foo2) Firefox and Safari log |
Quel cursed! |
So there is indeed a spec compliance bug in V8 for the |
Currently, JSC, V8, SM, and XS all do not throw on the following code,
contra spec:
This has been a bug in implementations for a decade
(https://bugzilla.mozilla.org/show_bug.cgi?id=605515), and is arguably
implementation reality not only for the web but for most
implementations.
This changes the spec to match the implemented re-resolution behavior.
Also see