Skip to content

fix: avoid panic in as_highlighted when column_number is 0#424

Open
SAY-5 wants to merge 1 commit into
rscarson:masterfrom
SAY-5:fix/highlight-zero-column-underflow
Open

fix: avoid panic in as_highlighted when column_number is 0#424
SAY-5 wants to merge 1 commit into
rscarson:masterfrom
SAY-5:fix/highlight-zero-column-underflow

Conversation

@SAY-5

@SAY-5 SAY-5 commented Jun 17, 2026

Copy link
Copy Markdown

Fixes #422.

A JsError whose first stack frame has column_number: Some(0) makes as_highlighted compute col - 1 on a zero usize, which panics with "attempt to subtract with overflow" in debug. Swapped that for saturating_sub(1) so the error formatter degrades gracefully instead of turning a captured JS error into a Rust panic, and added a regression test exercising the zero-column frame.

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
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.

Error::as_highlighted panics when formatting a JsError with column_number = 0

1 participant