Bug 189799
Summary: | [JSC] ForStatement should call CreatePerIterationEnvironment before first iteration | ||
---|---|---|---|
Product: | WebKit | Reporter: | Dasa Paddock <dpaddock> |
Component: | JavaScriptCore | Assignee: | Alexey Shvayka <ashvayka> |
Status: | RESOLVED FIXED | ||
Severity: | Normal | CC: | ashvayka, fpizlo, keith_miller, mark.lam, rwaldron, saam, webkit-bug-importer, webkit, ysuzuki |
Priority: | P2 | Keywords: | InRadar |
Version: | WebKit Nightly Build | ||
Hardware: | All | ||
OS: | All |
Dasa Paddock
Test code:
let callback1;
let callbacks2 = new Array();
let callbacks3 = new Array();
for (
let i = (callback1 = () => i, 0);
callbacks2.push(() => i), i < 5;
callbacks3.push(() => i), i++) {
// loop body
i++;
}
console.log(callback1());
console.log(callbacks2[0]());
console.log(callbacks3[0]());
Expected output (works in Chrome and Firefox)
0
1
3
Actual output in Safari TP 65:
1
1
3
Note: I found this test code at: https://github.com/Microsoft/TypeScript/issues/17632
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Radar WebKit Bug Importer
<rdar://problem/44730906>
Saam Barati
Thanks for the report. It looks like Chrome and Firefox are correct w.r.t the spec:
https://tc39.github.io/ecma262/#sec-for-statement-runtime-semantics-labelledevaluation
Rick Waldron
Just marking this as "covered" in Test262. https://github.com/tc39/test262/blob/master/test/language/statements/for/scope-body-lex-open.js
Dasa Paddock
I'm not sure when this was fixed, but I'm unable to repro in Safari 15.3.
Dasa Paddock
Sorry for the noise, this is still broken in Safari 15.3 and Safari TP 139.
Dasa Paddock
This is still broken in Safari TP 177.
Alexey Shvayka
*** Bug 257677 has been marked as a duplicate of this bug. ***
Alexey Shvayka
Pull request: https://github.com/WebKit/WebKit/pull/19403
EWS
Committed 269653@main (f32cd0f7cb79): <https://commits.webkit.org/269653@main>
Reviewed commits have been landed. Closing PR #19403 and removing active labels.