Repository navigation
fix(wasm): Number.isNaN / isFinite / isInteger / isSafeInteger on the web target - #14615
Conversation
|
Caution Review failedThe pull request is closed. No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
… web target The WASM emitter had no arm for `Expr::NumberIsNaN`, `NumberIsFinite`, `NumberIsInteger` or `NumberIsSafeInteger`, so all four fell through to the `TAG_UNDEFINED` catch-all, and string collection did not walk their argument. `Number.isNaN` / `isFinite` reuse the existing `is_nan` / `is_finite` bridges, which already implement the non-coercing Number versions; `isInteger` and `isSafeInteger` get bridges of their own. `number_predicates_answer_like_node` prints `undefined` twelve times without this change and matches Node with it. Refs PerryTS#14595. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CUQanVsnitcrmYLAWWPc3p
b118dbc to
d8d0e88
Compare
|
Rebased onto |
|
Also renamed the changelog fragment to |
Summary
On
--target web,Number.isNaN,Number.isFinite,Number.isIntegerandNumber.isSafeIntegerreturnundefined: the WASM emitter has no arm for the fourExpr::Number*predicates, so they fall through to theTAG_UNDEFINEDcatch-all. One of the gaps listed in #14595.Changes
emit/expr/regex_globals.rs: one arm for the four variants.Number.isNaN/Number.isFinitereuse the existingis_nan/is_finitebridges, which already implement the non-coercing Number versions.wasm_runtime.js:number_is_integerandnumber_is_safe_integerbridges.emit/string_collection.rs: interns the two new bridge names and walks the argument.emit/tests.rs:number_predicates_answer_like_node(including a string argument, which none of them coerce).Related issue
Refs #14595.
Noticed while reading this code, not changed here: the global
isNaN(x)lowers toExpr::IsNaN, which uses the same non-coercingis_nanbridge, soisNaN("abc")isfalseon the web target (Node:true). That needs its own bridge; separate PR.Test plan
Base
2d6ddf6d58(currentmain).undefined×12node --experimental-strip-typescargo test -p perry-codegen-wasmBuilt on macOS (Apple M6), nightly from
rust-toolchain.toml, LLVM 23.1.5, Node 26.13.1.rustfmt --checkon the touched Rust files.Checklist
feat:/fix:/docs:/chore:prefix convention used in the log🤖 Generated with Claude Code
https://claude.ai/code/session_01CUQanVsnitcrmYLAWWPc3p
Summary by CodeRabbit
Number.isNaN,Number.isFinite,Number.isInteger, andNumber.isSafeIntegerbehavior for web-targeted builds. These checks now return accurate results without coercing string arguments.