Skip to content

v0.4.2

Choose a tag to compare

@proggeramlug proggeramlug released this 23 Mar 14:16
· 4602 commits to main since this release

Strict Equality (===) Operator Fixes

Three bugs in the ===/!== operator have been fixed that caused incorrect comparison results:

expr === false / === true always returned true

The codegen boolean comparison path used ensure_i64() which strips NaN-boxing tags and collapses small values to 0. Both TAG_TRUE (payload 4) and TAG_FALSE (payload 3) were collapsed to 0, making every boolean literal comparison return true. Now uses raw bitcast to preserve full NaN-boxed bit patterns.

INT32 === float always returned false

js_jsvalue_equals had no handling for NaN-boxed INT32 values. Comparing INT32(5) (bits 0x7FFE...0005) with 5.0 (bits 0x4014...0000) failed on the fast-path bit check and fell through to "not equal". Added INT32→f64 coercion, matching what js_jsvalue_compare already did for </<=/>/>=.

Negative number equality/comparison broken

The number detection check bits < 0x7FF8_0000_0000_0000 is unsigned, so all negative f64 values (sign bit set → bits ≥ 0x8000...) were excluded from numeric comparison. This caused -0.0 === 0.0 to return false and broke negative number relational comparisons. Replaced with a proper tag-range check that correctly recognizes negative numbers.

Tests

Added unit tests covering boolean equality, INT32↔f64 cross-type equality, negative zero, and null/undefined strict comparisons.