Bug 291255
Summary: | `export async function` changes prototype to Function instead of AsyncFunction | ||
---|---|---|---|
Product: | WebKit | Reporter: | Jarred Sumner <jarred> |
Component: | JavaScriptCore | Assignee: | Yusuke Suzuki <ysuzuki> |
Status: | RESOLVED FIXED | ||
Severity: | Normal | CC: | keith_miller, webkit-bug-importer, ysuzuki |
Priority: | P2 | Keywords: | InRadar |
Version: | WebKit Nightly Build | ||
Hardware: | Unspecified | ||
OS: | Unspecified |
Jarred Sumner
The following code doesn't throw an error in node/v8 and does throw an error in JSC:
```
export async function a() {}
async function b() {}
async function c() {}
if (Object.getPrototypeOf(a) !== Object.getPrototypeOf(c)) {
throw new Error("Expected export declaration & export function to have same prototype");
}
if (Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)) {
throw new Error("Expected export & non-exported functions to have same prototype");
}
if (Object.getPrototypeOf(a).constructor !== Object.getPrototypeOf(c).constructor) {
throw new Error("Expected export declaration & export function to have same constructor");
}
if (Object.getPrototypeOf(a).constructor !== Object.getPrototypeOf(b).constructor) {
throw new Error("Expected export & non-exported functions to have same constructor");
}
if (Object.getPrototypeOf(a).constructor.name !== "AsyncFunction") {
throw new Error("Expected AsyncFunction");
}
globalThis.print ??= console.log;
const AsyncFunction = Object.getPrototypeOf(a).constructor;
// This should not throw
new AsyncFunction("await 42")();
export { c };
```
Originally reported in https://github.com/oven-sh/bun/issues/18137
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Radar WebKit Bug Importer
<rdar://problem/149083588>
Yusuke Suzuki
Pull request: https://github.com/WebKit/WebKit/pull/43970
EWS
Committed 293602@main (910c1b00a197): <https://commits.webkit.org/293602@main>
Reviewed commits have been landed. Closing PR #43970 and removing active labels.