Skip to content
PR Quorum
Sign inStart free
← Review gallery
denoland/deno #36028openreviewed 6h ago

fix: handle UTF-16 diagnostic columns

by nathanwhit+142 222 filesreviewed in 56sView PR on GitHub
needs attentionThe panel surfaced issues that deserve attention before merge.2 findings · 1 high+

Reviewer panel

Correctness
deepseek/deepseek-v4-flash
1 found
Security
deepseek/deepseek-v4-flash
0 found
Architecture
deepseek/deepseek-v4-flash
1 found

Findings

01Hhighconf 85%

Potential out-of-bounds read via encode_utf16 on non-BMP character boundary

cli/tsc/diagnostics.rs:348

On line 348, the code checks end.character > source_line.encode_utf16().count() as u64 before computing length. However, end.character is a UTF-16 code unit offset (start of a character that is exactly one or two code units). If the reported character offset falls inside a surrogate pair (i.e., points to the second code unit of a 4-byte character like 😀, which is U+1F600, encoded as surrogate pair 0xD83D 0xDE00), then the inequality end.character > count might be false (it's still ≤ count), but the subsequent formatting logic that builds an underline sequence of '~' characters will still use this offset and produce either a misaligned or a truncated marker. This is a correctness bug for diagnostics that point into the second half of a surrogate pair (unlikely but possible if the runtime/TSC reports such internal positions). The earlier boundary check next_utf16 > column_utf16 already returns None in source_line_prefix, so the start side is safe, but the end side length computation does not guard against this case.

02Llowconf 100%

Duplicate `source_line_prefix` function across two files

cli/tsc/diagnostics.rs:18

The same source_line_prefix function is defined in both cli/tsc/diagnostics.rs (line 18) and runtime/fmt_errors.rs (line 126) with identical implementations. This duplication violates DRY and increases maintenance burden — any future fix or enhancement must be applied in two places, and they can easily drift apart. Consider extracting it into a shared module accessible to both crates.

Want this on your own pull requests?
The same reviewer panel runs on every PR — one focused review, no noise.
Start freeLive demo