Bug 297532
| Summary: | [JSC] Fix `Iterator#flatMap` to handle iterators without `return` method | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Sosuke Suzuki <aosukeke> |
| Component: | JavaScriptCore | Assignee: | Sosuke Suzuki <aosukeke> |
| Status: | RESOLVED FIXED | ||
| Severity: | Normal | CC: | webkit-bug-importer |
| Priority: | P2 | Keywords: | InRadar |
| Version: | WebKit Nightly Build | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
Sosuke Suzuki
According to the spec, IteratorClose should check if the return method
exists before calling it, returning the completion value unchanged when
the method is undefined.
However, the current implementation of Iterator.prototype.flatMap unconditionally
calls iterated.return(), causing a TypeError when used with iterators that don't
have a return method (e.g., Map.prototype.entries(), Set.prototype.values()).
This patch fixes the issue by checking if the return method exists before calling
it.
original report https://github.com/oven-sh/bun/issues/17518
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Sosuke Suzuki
Pull request: https://github.com/WebKit/WebKit/pull/49530
EWS
Committed 298966@main (c4fa114ca0b7): <https://commits.webkit.org/298966@main>
Reviewed commits have been landed. Closing PR #49530 and removing active labels.
Radar WebKit Bug Importer
<rdar://problem/158783404>