Skip to content

fix: handle UTF-16 diagnostic columns - #36028

Merged
nathanwhit merged 2 commits into
denoland:mainfrom
nathanwhit:fix/utf16-diagnostic-columns
Jul 21, 2026
Merged

nathanwhit merged 2 commits into
denoland:mainfrom
nathanwhit:fix/utf16-diagnostic-columns

Conversation

@nathanwhit

Copy link
Copy Markdown
Member

Summary

  • interpret runtime and TypeScript diagnostic columns as UTF-16 code-unit offsets
  • preserve tabs and spacing when building source-line underlines
  • omit an underline or show the existing warning when a position is not a valid source boundary

Why

V8 and TypeScript report source columns in UTF-16 code units, while Rust strings are UTF-8 and iterate by Unicode scalar value. Treating the reported column as a scalar index produces incorrect source-line formatting for non-BMP characters and can prevent the original diagnostic from being displayed.

Validation

  • ./tools/format.js
  • cargo fmt --check --package deno_runtime --package deno
  • CARGO_TARGET_DIR=target cargo test -p deno_runtime fmt_errors --lib -- --nocapture
  • CARGO_TARGET_DIR=target cargo test -p deno tsc::diagnostics -- --nocapture
  • CARGO_TARGET_DIR=target cargo build --bin deno
  • runtime and deno check smokes with non-BMP source lines

@nathanwhit
nathanwhit marked this pull request as ready for review July 14, 2026 02:24
@deepshekhardas

This comment was marked as spam.

@nathanwhit
nathanwhit merged commit 3f46264 into denoland:main Jul 21, 2026
136 checks passed
bartlomieju pushed a commit that referenced this pull request Jul 23, 2026
- interpret runtime and TypeScript diagnostic columns as UTF-16
code-unit offsets
- preserve tabs and spacing when building source-line underlines
- omit an underline or show the existing warning when a position is not
a valid source boundary

V8 and TypeScript report source columns in UTF-16 code units, while Rust
strings are UTF-8 and iterate by Unicode scalar value. Treating the
reported column as a scalar index produces incorrect source-line
formatting for non-BMP characters and can prevent the original
diagnostic from being displayed.

- `./tools/format.js`
- `cargo fmt --check --package deno_runtime --package deno`
- `CARGO_TARGET_DIR=target cargo test -p deno_runtime fmt_errors --lib
-- --nocapture`
- `CARGO_TARGET_DIR=target cargo test -p deno tsc::diagnostics --
--nocapture`
- `CARGO_TARGET_DIR=target cargo build --bin deno`
- runtime and `deno check` smokes with non-BMP source lines
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