biomejs/biome · error

integer overflow

Error message

integer overflow

What it means

Error "integer overflow" thrown in biomejs/biome.

Source

Thrown at crates/biome_diagnostics/src/location.rs:300

    fn as_span(&self) -> Option<TextRange> {
        T::as_span(*self)
    }
}

impl AsSpan for TextRange {
    fn as_span(&self) -> Option<TextRange> {
        Some(*self)
    }
}

impl<T: Copy> AsSpan for Range<T>
where
    TextSize: TryFrom<T>,
    <TextSize as TryFrom<T>>::Error: Debug,
{
    fn as_span(&self) -> Option<TextRange> {
        Some(TextRange::new(
            TextSize::try_from(self.start).expect("integer overflow"),
            TextSize::try_from(self.end).expect("integer overflow"),
        ))
    }
}

/// Utility trait for types that can be converted into [SourceCode]
pub trait AsSourceCode {
    fn as_source_code(&self) -> Option<BorrowedSourceCode<'_>>;
}

impl<T: AsSourceCode> AsSourceCode for Option<T> {
    fn as_source_code(&self) -> Option<BorrowedSourceCode<'_>> {
        self.as_ref().and_then(T::as_source_code)
    }
}

impl<T: AsSourceCode> AsSourceCode for Box<T> {
    fn as_source_code(&self) -> Option<BorrowedSourceCode<'_>> {

View on GitHub (pinned to 405dedb0ff)

Solutions

  1. Ensure byte offsets used for diagnostics fall within the source text length.
  2. Guard location conversions with checked arithmetic when offsets come from untrusted input.

Example fix

let offset = TextSize::try_from(u64_value).map_err(|_| io::Error::new(ErrorKind::InvalidInput, "integer overflow"))?;

When it happens

Trigger: Thrown at crates/biome_diagnostics/src/location.rs:300 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of biomejs/biome@405dedb0ff (2026-08-20). Data as JSON: /api/errors/6f580160ad29dd53. Report an issue: GitHub.