Repository navigation
Fix emscripten_get_exported_function for names that are not exported - #28207
Conversation
With ASSERTIONS, a name that is not exported printed the text
`No exported function found by name "{exportedFunc}"`: the template
literal had no `$`, and `exportedFunc` is always undefined there. Print the
name that was looked up.
There was a problem hiding this comment.
Code Review
This pull request fixes an error message in src/lib/libexports.js when an exported function is not found, correcting the string interpolation to use ${name} instead of {exportedFunc}. Additionally, a new test test_get_exported_function_missing is added to test/test_other.py to verify this behavior under assertions. There are no review comments to address, and I have no feedback to provide.
sbc100
left a comment
There was a problem hiding this comment.
Rather than add a new test can you update the existing test/core/test_get_exported_function.cpp?
Move the check from other.test_get_exported_function_missing into core/test_get_exported_function.cpp, as asked in review. The test now also looks up a name that is not exported and expects NULL. The error that names it is checked in unoptimized modes, where ASSERTIONS is on by default; the optimized modes keep their default settings, so they still cover the -lexports.js export name handling. In the wasm64 modes that lookup threw "Cannot convert undefined to a BigInt", with or without ASSERTIONS: the function fell off the end and returned undefined, which the pointer return wrapper passes to BigInt. Return 0 explicitly.
|
Done, thanks: the check now lives in test/core/test_get_exported_function.cpp and the test_other test is gone. The message is only checked in unoptimized modes, so the -O3/-Os/-Oz modes keep testing that |
For a name that is not exported,
emscripten_get_exported_function:ASSERTIONS, printedNo exported function found by name "{exportedFunc}": the template literal had no$, andexportedFuncis always undefined at that point. It now prints the name that was looked up.Cannot convert undefined to a BigInt: the function fell off the end and returnedundefined, which the pointer return wrapper passes toBigInt. It now returns 0.core/test_get_exported_function.cppnow also looks up a missing name and expects NULL, and the test checks the message in unoptimized modes (whereASSERTIONSis on by default). Without the fix it fails in core0 (message) and in wasm64 and wasm64_O2 (TypeError).Follow-up to #28177.