Skip to content

fix(ext/node): handle UTF-16 assert source positions#36029

Merged
bartlomieju merged 1 commit into
denoland:mainfrom
nathanwhit:fix/node-assert-utf16-columns
Jul 14, 2026
Merged

fix(ext/node): handle UTF-16 assert source positions#36029
bartlomieju merged 1 commit into
denoland:mainfrom
nathanwhit:fix/node-assert-utf16-columns

Conversation

@nathanwhit

Copy link
Copy Markdown
Member

Summary

  • translate V8 UTF-16 source columns to checked UTF-8 byte offsets
  • fall back to the full source line when a reported position is not a valid character boundary
  • keep the final assertion-expression slice checked

Why

The node:assert source-expression formatter receives a UTF-16 column from V8 but slices a Rust UTF-8 string. The previous approximation handled some non-ASCII text but could produce an invalid byte boundary for multibyte characters.

Validation

  • ./tools/format.js
  • cargo fmt --check --package deno_node
  • CARGO_TARGET_DIR=target cargo test -p deno_node ops::assert::tests --lib -- --nocapture
  • CARGO_TARGET_DIR=target cargo build --bin deno
  • target/debug/deno test -A tests/unit_node/assert_test.ts
  • assertion-expression smoke with a multibyte identifier

@nathanwhit
nathanwhit marked this pull request as ready for review July 14, 2026 02:24
@bartlomieju bartlomieju changed the title fix(node): handle UTF-16 assert source positions fix(ext/node): handle UTF-16 assert source positions Jul 14, 2026
@bartlomieju
bartlomieju merged commit b8b7f50 into denoland:main Jul 14, 2026
305 of 307 checks passed
bartlomieju pushed a commit that referenced this pull request Jul 15, 2026
## Summary

- translate V8 UTF-16 source columns to checked UTF-8 byte offsets
- fall back to the full source line when a reported position is not a
valid character boundary
- keep the final assertion-expression slice checked

## Why

The `node:assert` source-expression formatter receives a UTF-16 column
from V8 but slices a Rust UTF-8 string. The previous approximation
handled some non-ASCII text but could produce an invalid byte boundary
for multibyte characters.
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.

2 participants