Repository navigation
fix(wasm): the global isNaN / isFinite coerce their argument - #14619
Conversation
`Expr::IsNaN` and `Expr::IsFinite` (the global `isNaN` / `isFinite`, their
only producers) used the `is_nan` / `is_finite` bridges, which implement the
non-coercing `Number.isNaN` / `Number.isFinite`. So on the web target
`isNaN("abc")` and `isNaN(undefined)` were false and `isFinite("1")` was
false. They now call `global_is_nan` / `global_is_finite`, which apply
ToNumber. `is_nan` / `is_finite` keep their meaning for their other users
(`IsUndefinedOrBareNan`, and `Number.isNaN` / `isFinite`).
`global_is_nan_and_is_finite_coerce_like_node` prints the non-coercing answers
(`false false false true false` / `false false false true`) with the old
bridges.
Refs PerryTS#14595.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CUQanVsnitcrmYLAWWPc3p
|
Caution Review failedThe pull request is closed. No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Summary
On
--target web, the globalisNaNandisFinitedo not apply ToNumber:isNaN("abc")andisNaN(undefined)arefalse,isFinite("1")isfalse(Node:truefor all three).Expr::IsNaN/Expr::IsFinite— produced only by the global functions — use theis_nan/is_finitebridges, which implement the non-coercingNumber.isNaN/Number.isFinite. Listed in #14595.Changes
wasm_runtime.js:global_is_nan/global_is_finitebridges that call the global functions.emit/expr/regex_globals.rs:Expr::IsNaN/Expr::IsFinitecall them.is_nan/is_finitekeep their non-coercing meaning forIsUndefinedOrBareNanand forNumber.isNaN/Number.isFinite(fix(wasm): Number.isNaN / isFinite / isInteger / isSafeInteger on the web target #14615).emit/string_collection.rs: interns the two names.emit/tests.rs:global_is_nan_and_is_finite_coerce_like_node.Related issue
Refs #14595.
Test plan
Base
46b2339d82(currentmain).false false false true false/false false false truenode --experimental-strip-typescargo test -p perry-codegen-wasmtests/integration/wasm/run_wasm_tests.shisNaN/isFinite)The integration suite ran before the final rebase onto
46b2339d82; the unit tests were re-run after it. Built on macOS (Apple M6), nightly fromrust-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
isNaNandisFinitenow coerce inputs like their JavaScript counterparts, so values such as strings andundefinedproduce the expected results.