{"record":{"id":"8ccf1633623cae8a","repo":"oxc-project/oxc","slug":"line-break-count-must-fit-in-u32","errorCode":null,"errorMessage":"line break count must fit in u32","messagePattern":"line break count must fit in u32","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/oxc_formatter_core/src/write/builders.rs","lineNumber":88,"sourceCode":"/// For blank runs inside verbatim values (block scalars, block strings),\n/// where the number of line breaks IS the value and must not be normalized.\n/// From a mid-line position the first break ends the current line, leaving `count - 1` blank lines;\n/// from the start of a line all `count` breaks become blank lines.\n///\n/// Unlike [hard_line_break]:\n/// - the breaks always print, regardless of the current line or a preceding blank line\n/// - consecutive calls accumulate, nothing is collapsed or capped\n///\n/// The blank lines themselves carry no indention;\n/// the NEXT line starts at the current indention (same re-arming as [hard_line_break]).\n///\n/// # Panics\n/// When `count == 0` or `count > u32::MAX`.\n/// Both are unreachable from source-derived callers: a source of N bytes cannot hold more than N line breaks,\n/// and sources are capped at `u32::MAX` by `oxc_span::Span`.\n#[inline]\npub fn exact_line_breaks(count: usize) -> Line {\n    let count = u32::try_from(count).expect(\"line break count must fit in u32\");\n    let count = std::num::NonZeroU32::new(count).expect(\"line break count must be >= 1\");\n    Line::new(LineMode::ExactLineBreaks(count))\n}\n\n/// A forced line break that starts the next line at the marked root indention (Prettier's `literalline`).\n///\n/// Unlike [hard_line_break]:\n/// - pending whitespace on the current line materializes as-is (never dropped)\n/// - the newline always prints, even on an empty line\n/// - the next line starts at the [mark_as_root] indention (column 0 when unmarked)\n///   instead of the current indention\n///\n/// Used for verbatim multi-line content whose line structure is built element by element (e.g. YAML block scalars).\n/// For verbatim content held as ONE string,\n/// a multiline [text] already prints its embedded newlines with these semantics.\n///\n/// Known divergence from Prettier:\n/// a [hard_line_break] directly after a literal line is absorbed by","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/oxc-project/oxc/blob/1f902a69625cd14e6d8dc58feca94da099d2d251/crates/oxc_formatter_core/src/write/builders.rs#L70-L106","documentation":"Assertion in the formatter's exact_line_breaks builder: the requested line-break count is accumulated into a u32 counter (with checked adds), so a count that does not fit in u32 cannot be represented and the builder panics up front rather than silently truncating verbatim blank-line output.","triggerScenarios":"Thrown at crates/oxc_formatter_core/src/write/builders.rs:75 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Clamp or split the break count into batches that each fit in u32","Emit the blank lines via multiple exact_line_breaks calls instead of one huge count"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"1f902a69625cd14e6d8dc58feca94da099d2d251","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}