biomejs/biome · error · io::Error

overflow error

Error message

overflow error

What it means

Error "overflow error" thrown in biomejs/biome.

Source

Thrown at crates/biome_diagnostics/src/display/frame.rs:648

                || Cow::Owned(LineIndexBuf::from_source_text(source_code.text)),
                Cow::Borrowed,
            ),
        }
    }

    /// Return the starting byte index of the line with the specified line index.
    /// Convenience method that already generates errors if necessary.
    fn line_start(&self, line_index: usize) -> io::Result<TextSize> {
        use std::cmp::Ordering;

        match line_index.cmp(&self.line_starts.len()) {
            Ordering::Less => Ok(self
                .line_starts
                .get(line_index)
                .copied()
                .expect("failed despite previous check")),
            Ordering::Equal => Ok(self.source.text_len()),
            Ordering::Greater => Err(io::Error::new(
                io::ErrorKind::InvalidInput,
                "overflow error",
            )),
        }
    }

    fn line_index(&self, byte_index: TextSize) -> usize {
        self.line_starts
            .binary_search(&byte_index)
            .unwrap_or_else(|next_line| next_line - 1)
    }

    fn line_range(&self, line_index: usize) -> io::Result<TextRange> {
        let line_start = self.line_start(line_index)?;
        let next_line_start = self.line_start(line_index + 1)?;

        Ok(TextRange::new(line_start, next_line_start))
    }

View on GitHub (pinned to 405dedb0ff)

Solutions

  1. Ensure the requested line index does not exceed the number of lines in the file being rendered.
  2. Validate the diagnostic location before building the code frame.

Example fix

Clamp the diagnostic's line index to `line_starts.len()` before calling `line_start`.

When it happens

Trigger: Thrown at crates/biome_diagnostics/src/display/frame.rs:648 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/819cf85c1ab0e079. Report an issue: GitHub.