Skip to content

fix: prevent divide-by-zero in padstart/padend with empty pad string#227

Merged
cs01 merged 1 commit intomainfrom
fix/padstart-divzero
Mar 11, 2026
Merged

fix: prevent divide-by-zero in padstart/padend with empty pad string#227
cs01 merged 1 commit intomainfrom
fix/padstart-divzero

Conversation

@cs01
Copy link
Copy Markdown
Owner

@cs01 cs01 commented Mar 11, 2026

Summary

  • "hello".padStart(10, "") previously caused a divide-by-zero crash in the compiled binary
  • Added guard: skip padding when pad string is empty (matches JS behavior — returns original string)
  • Same fix applied to both padStart and padEnd

Test plan

  • New test fixture string-pad-empty.ts covers padStart/padEnd with empty string, space, and shorter target
  • npm run verify:quick passes (tests + stage 1 self-hosting)

@cs01 cs01 merged commit 3fc6d35 into main Mar 11, 2026
12 checks passed
@cs01 cs01 deleted the fix/padstart-divzero 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