From 139c941ff1a393def74d20a36b396309ff6052d1 Mon Sep 17 00:00:00 2001 From: Dmitry Vasilev Date: Sun, 15 Jan 2023 21:28:40 +0800 Subject: [PATCH] Promise.then non-function callback --- src/eval.js | 4 ++-- test/test.js | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/eval.js b/src/eval.js index 39c83ca..bf4dce6 100644 --- a/src/eval.js +++ b/src/eval.js @@ -303,8 +303,8 @@ export const eval_modules = ( } let children_copy = children - const make_callback = cb => cb == null - ? null + const make_callback = cb => typeof(cb) != 'function' + ? cb : value => { const current = children children = children_copy diff --git a/test/test.js b/test/test.js index bedb59e..14e11f5 100644 --- a/test/test.js +++ b/test/test.js @@ -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 () => { const i = await test_initial_state_async(` const x = () => 1