{"record":{"id":"df99bcbb0ae9e8e7","repo":"oxc-project/oxc","slug":"line-break-count-must-be-1","errorCode":null,"errorMessage":"line break count must be >= 1","messagePattern":"line break count must be >= 1","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/oxc_formatter_core/src/write/builders.rs","lineNumber":89,"sourceCode":"/// 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\n/// the printer's \"only print a newline if the line isn't already empty\" rule","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/oxc-project/oxc/blob/5b3e33548431073728dcf409f0844851804cae0a/crates/oxc_formatter_core/src/write/builders.rs#L71-L107","documentation":"Assertion in exact_line_breaks: unlike hard_line_break, this builder guarantees the breaks always print, so a count of 0 (which would print nothing and break that contract) is rejected via expect before the element is built.","triggerScenarios":"Thrown at crates/oxc_formatter_core/src/write/builders.rs:76 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Skip the exact_line_breaks call entirely when the count is 0","Use if count > 0 { ... } around the builder call"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5b3e33548431073728dcf409f0844851804cae0a","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}