mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-09 17:49:40 +00:00
LibJS: Perform TLA async function construction in the module context
Previously it was only pushing the module context for the call to
capture the module execution context. This is incorrect, as the capture
occurs upon function construction. This resulted in it capturing the
execution context that execute_module was called from, instead of the
newly created module_context.
f87041bf3a/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp (L92)
This can be demonstrated with the following setup:
index.html:
```html
<script>
var foo = 1;
</script>
<script type="module">
import {test} from "./scriptA.mjs";
</script>
```
scriptA.mjs:
```js
function foo() {
return {a: "b"};
}
export let test = await foo();
```
Before this fix, this would throw:
```
[TypeError] 1 is not a function (evaluated from 'foo')
at module code with top-level await
at module code with top-level await
at <unknown>
at <unknown>
```
Fixes #2245.
This commit is contained in:
parent
1383d03c02
commit
6319dedbcd
Notes:
github-actions[bot]
2024-11-15 18:36:18 +00:00
Author: https://github.com/Lubrsi
Commit: 6319dedbcd
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2362
3 changed files with 39 additions and 4 deletions
|
@ -9,3 +9,9 @@ export default "Default export";
|
|||
await Promise.resolve(2);
|
||||
|
||||
export const bar = "'bar' export";
|
||||
|
||||
async function baz() {
|
||||
return "'qux' export";
|
||||
}
|
||||
|
||||
export const qux = await baz();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue