Skip to content

fix: clamp negative deletecount in splice, fix assert.notequal nan (#266)#266

Merged
cs01 merged 1 commit intomainfrom
fix/splice-negative-deletecount
Mar 12, 2026
Merged

fix: clamp negative deletecount in splice, fix assert.notequal nan (#266)#266
cs01 merged 1 commit intomainfrom
fix/splice-negative-deletecount

Conversation

@cs01
Copy link
Copy Markdown
Owner

@cs01 cs01 commented Mar 12, 2026

Summary

  • arr.splice(i, -1) with negative deleteCount was passed through as-is, then zext i32 -1 to i64 produced 0xFFFFFFFF (4GB), causing massive memcpy and memory corruption. Now clamped to 0.
  • Also changed zext to sext for splice size calculations (safety against any remaining negative edge cases)
  • Fixed assert.notEqual using fcmp one instead of fcmp uneassert.notEqual(NaN, NaN) incorrectly failed because one returns false when either operand is NaN

Test plan

  • npm run verify:quick passes (tests + Stage 1 self-hosting)
  • New test: arrays/splice-negative-deletecount.ts — splice with -1, 0, positive, and negative start

🤖 Generated with Claude Code

@cs01 cs01 merged commit c917409 into main Mar 12, 2026
18 of 19 checks passed
@cs01 cs01 deleted the fix/splice-negative-deletecount branch March 12, 2026 05:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant