{"record":{"id":"2844e5fa52dd52bf","repo":"typst/typst","slug":"cannot-draw-a-horizontal-line-at-offset-offset-i","errorCode":null,"errorMessage":"cannot draw a horizontal line at offset {offset} in a matrix with {nrows} rows","messagePattern":"cannot draw a horizontal line at offset (.+?) in a matrix with (.+?) rows","errorType":"validation","errorClass":"SourceDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/typst-library/src/math/ir/resolve.rs","lineNumber":1045,"sourceCode":"\n/// Resolves a matrix element.\nfn resolve_mat<'a>(\n    elem: &'a Packed<MatElem>,\n    ctx: &mut MathResolver<'a, '_, '_>,\n    styles: StyleChain<'a>,\n) -> SourceResult<()> {\n    let span = elem.span();\n\n    let rows: Vec<Vec<&Content>> =\n        elem.rows.iter().map(|row| row.iter().collect()).collect();\n    let nrows = rows.len();\n    let ncols = rows.first().map_or(0, |row| row.len());\n\n    let augment = elem.augment.resolve(styles);\n    if let Some(aug) = &augment {\n        for &offset in &aug.hline.0 {\n            if offset > nrows as isize || offset.unsigned_abs() > nrows {\n                bail!(\n                    span,\n                    \"cannot draw a horizontal line at offset {offset} \\\n                     in a matrix with {nrows} rows\",\n                );\n            }\n        }\n\n        for &offset in &aug.vline.0 {\n            if offset > ncols as isize || offset.unsigned_abs() > ncols {\n                bail!(\n                    span,\n                    \"cannot draw a vertical line at offset {offset} \\\n                     in a matrix with {ncols} columns\",\n                );\n            }\n        }\n    }\n","sourceCodeStart":1027,"sourceCodeEnd":1063,"githubUrl":"https://github.com/typst/typst/blob/35417aa769ab9d699a60384f91082b09bc6ba421/crates/typst-library/src/math/ir/resolve.rs#L1027-L1063","documentation":"Raised in resolve_mat while resolving matrix augmentation: an `hline` offset in the augment dictionary is out of range for the matrix's number of rows (positive offsets must be ≤ rows, negative ones within bounds counting from the end).","triggerScenarios":"Thrown at crates/typst-library/src/math/ir/resolve.rs:1045 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use an hline offset between 0 and the number of rows","Use negative offsets to count rows from the bottom"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"35417aa769ab9d699a60384f91082b09bc6ba421","analyzedAt":"2026-08-17T21:03:48.984Z","contentChangedAt":"2026-08-17T21:03:48.984Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}