From 7ac1a3d7674a8c05702d22ebe40e7d43d8f4310c Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Sat, 9 May 2026 19:19:14 -0700 Subject: [PATCH] Remove redundant assertion from emscripten_console_* functions. NFC The UTF8ToString functions that these all call has this assertion already and with a useful message. --- src/lib/libcore.js | 47 ++++++++++------------------------------------ 1 file changed, 10 insertions(+), 37 deletions(-) diff --git a/src/lib/libcore.js b/src/lib/libcore.js index 0778fd90fc589..f11d16b4c02e9 100644 --- a/src/lib/libcore.js +++ b/src/lib/libcore.js @@ -1967,44 +1967,17 @@ addToLibrary({ _emscripten_get_progname__deps: ['$getExecutableName', '$stringToUTF8'], _emscripten_get_progname: (str, len) => stringToUTF8(getExecutableName(), str, len), - emscripten_console_log: (str) => { -#if ASSERTIONS - assert(typeof str == 'number'); -#endif - console.log(UTF8ToString(str)); - }, - - emscripten_console_warn: (str) => { -#if ASSERTIONS - assert(typeof str == 'number'); -#endif - console.warn(UTF8ToString(str)); - }, + // These single-line arrow functions use curly braces since otherwise closure + // compiler will inject a extra `return` keyword when inlining. + // https://github.com/emscripten-core/emscripten/issues/26922 + emscripten_console_log: (str) => { console.log(UTF8ToString(str)) }, + emscripten_console_warn: (str) => { console.warn(UTF8ToString(str)) }, + emscripten_console_error: (str) => { console.error(UTF8ToString(str)) }, + emscripten_console_trace: (str) => { console.trace(UTF8ToString(str)) }, - emscripten_console_error: (str) => { -#if ASSERTIONS - assert(typeof str == 'number'); -#endif - console.error(UTF8ToString(str)); - }, + emscripten_throw_number: (number) => { throw number; }, - emscripten_console_trace: (str) => { -#if ASSERTIONS - assert(typeof str == 'number'); -#endif - console.trace(UTF8ToString(str)); - }, - - emscripten_throw_number: (number) => { - throw number; - }, - - emscripten_throw_string: (str) => { -#if ASSERTIONS - assert(typeof str == 'number'); -#endif - throw UTF8ToString(str); - }, + emscripten_throw_string: (str) => { throw UTF8ToString(str); }, #if !MINIMAL_RUNTIME #if STACK_OVERFLOW_CHECK @@ -2185,7 +2158,7 @@ addToLibrary({ $alignMemory: (size, alignment) => { #if ASSERTIONS - assert(alignment, "alignment argument is required"); + assert(alignment, 'alignment argument is required'); #endif return Math.ceil(size / alignment) * alignment; },