Promise.then non-function callback

This commit is contained in:
Dmitry Vasilev
2023-01-15 21:28:40 +08:00
parent 723296a46c
commit 139c941ff1
2 changed files with 11 additions and 2 deletions

View File

@@ -303,8 +303,8 @@ export const eval_modules = (
} }
let children_copy = children let children_copy = children
const make_callback = cb => cb == null const make_callback = cb => typeof(cb) != 'function'
? null ? cb
: value => { : value => {
const current = children const current = children
children = children_copy children = children_copy

View File

@@ -2818,6 +2818,15 @@ const y = x()`
) )
}), }),
test('async/await then non-function', async () => {
await assert_code_evals_to_async(
`
await Promise.resolve(1).then(2)
`,
1
)
}),
test('async/await Promise.then creates subcall', async () => { test('async/await Promise.then creates subcall', async () => {
const i = await test_initial_state_async(` const i = await test_initial_state_async(`
const x = () => 1 const x = () => 1