diff --git a/tests/lang/typ/arrays.typ b/tests/lang/typ/arrays.typ index 3c290e50d..c91a5ac18 100644 --- a/tests/lang/typ/arrays.typ +++ b/tests/lang/typ/arrays.typ @@ -17,11 +17,11 @@ ,)} // Missing closing paren. -// Error: 1:3-1:3 expected closing paren +// Error: 3-3 expected closing paren {(} // Not an array. -// Error: 1:2-1:3 expected expression, found closing paren +// Error: 2-3 expected expression, found closing paren {)} // Missing comma and bad expression. @@ -30,17 +30,17 @@ {(1*/2)} // Bad expression. -// Error: 1:6-1:8 expected expression, found invalid token +// Error: 6-8 expected expression, found invalid token {(1, 1u 2)} // Leading comma is not an expression. -// Error: 1:3-1:4 expected expression, found comma +// Error: 3-4 expected expression, found comma {(,1)} // Missing expression makes named pair incomplete, making this an empty array. -// Error: 1:5-1:5 expected expression +// Error: 5-5 expected expression {(a:)} // Named pair after this is already identified as an array. -// Error: 1:6-1:10 expected expression, found named pair +// Error: 6-10 expected expression, found named pair {(1, b: 2)} diff --git a/tests/lang/typ/blocks.typ b/tests/lang/typ/blocks.typ index 7ef34b8ad..b2691ffb1 100644 --- a/tests/lang/typ/blocks.typ +++ b/tests/lang/typ/blocks.typ @@ -5,13 +5,13 @@ {1} // Bad expression. -// Error: 1:2-1:4 expected expression, found invalid token +// Error: 2-4 expected expression, found invalid token {1u} // Missing closing brace in nested block. -// Error: 1:5-1:5 expected closing brace +// Error: 5-5 expected closing brace {({1) + 1} // Missing closing bracket in template expression. -// Error: 1:11-1:11 expected closing bracket +// Error: 11-11 expected closing bracket {[_] + [3_} diff --git a/tests/lang/typ/bracket-call.typ b/tests/lang/typ/bracket-call.typ index 46757c45b..a2d563c68 100644 --- a/tests/lang/typ/bracket-call.typ +++ b/tests/lang/typ/bracket-call.typ @@ -33,14 +33,14 @@ #[f|f|f] // With body. -// Error: 1:7-1:8 expected identifier, found integer +// Error: 7-8 expected identifier, found integer #[f | 1 | box][💕] // Error: 2:3-2:3 expected identifier // Error: 1:4-1:4 expected identifier #[||f true] -// Error: 1:7-1:7 expected identifier +// Error: 7-7 expected identifier #[f 1|] // Error: 2:3-2:3 expected identifier @@ -55,23 +55,23 @@ #[box width: 1cm | image "res/rhino.png"] --- -// Error: 1:5-1:7 expected expression, found end of block comment +// Error: 5-7 expected expression, found end of block comment #[f */] -// Error: 1:8-1:9 expected expression, found colon +// Error: 8-9 expected expression, found colon #[f a:1:] -// Error: 1:6-1:6 expected comma +// Error: 6-6 expected comma #[f 1 2] // Error: 2:5-2:6 expected identifier // Error: 1:7-1:7 expected expression #[f 1:] -// Error: 1:5-1:6 expected identifier +// Error: 5-6 expected identifier #[f 1:2] -// Error: 1:5-1:8 expected identifier +// Error: 5-8 expected identifier #[f (x):1] --- @@ -80,7 +80,7 @@ #let x = "string" #[x] -// Error: 1:3-1:4 expected identifier, found invalid token +// Error: 3-4 expected identifier, found invalid token #[# 1] // Error: 4:1-4:1 expected identifier diff --git a/tests/lang/typ/comments.typ b/tests/lang/typ/comments.typ index 880e8c2b5..3cabb5869 100644 --- a/tests/lang/typ/comments.typ +++ b/tests/lang/typ/comments.typ @@ -12,7 +12,7 @@ C/* , 1] // End should not appear without start. -// Error: 1:7-1:9 unexpected end of block comment +// Error: 7-9 unexpected end of block comment /* */ */ // Unterminated is okay. diff --git a/tests/lang/typ/dictionaries.typ b/tests/lang/typ/dictionaries.typ index 63d9db9ec..4f9e0f608 100644 --- a/tests/lang/typ/dictionaries.typ +++ b/tests/lang/typ/dictionaries.typ @@ -5,7 +5,7 @@ {(one: 1, two: 2)} // Simple expression after this is already identified as a dictionary. -// Error: 1:9-1:10 expected named pair, found expression +// Error: 9-10 expected named pair, found expression {(a: 1, b)} // Identified as dictionary by initial colon. diff --git a/tests/lang/typ/escaping.typ b/tests/lang/typ/escaping.typ index abf124ce9..57d8ec689 100644 --- a/tests/lang/typ/escaping.typ +++ b/tests/lang/typ/escaping.typ @@ -19,9 +19,9 @@ \u{41} vs. \\u\{41\} // Unicode codepoint does not exist. -// Error: 1:1-1:11 invalid unicode escape sequence +// Error: 1-11 invalid unicode escape sequence \u{FFFFFF} // Unterminated. -// Error: 1:6-1:6 expected closing brace +// Error: 6-6 expected closing brace \u{41*Bold* diff --git a/tests/lang/typ/expressions.typ b/tests/lang/typ/expressions.typ index eee400854..167d0d1a7 100644 --- a/tests/lang/typ/expressions.typ +++ b/tests/lang/typ/expressions.typ @@ -3,7 +3,7 @@ #let a = 2 #let b = 4 -// Error: 1:14-1:17 cannot apply '+' to string +// Error: 14-17 cannot apply '+' to string #let error = +"" // Paren call. @@ -77,16 +77,16 @@ { x = "some" } #[test x, "some"] { x += "thing" } #[test x, "something"] -// Error: 1:3-1:4 unknown variable +// Error: 3-4 unknown variable { z = 1 } -// Error: 1:3-1:6 cannot assign to this expression +// Error: 3-6 cannot assign to this expression { (x) = "" } -// Error: 1:3-1:8 cannot assign to this expression +// Error: 3-8 cannot assign to this expression { 1 + 2 = 3} -// Error: 1:3-1:6 cannot assign to a constant +// Error: 3-6 cannot assign to a constant { box = "hi" } // Works if we define box before (since then it doesn't resolve to the standard @@ -98,23 +98,23 @@ #[test (2), 2] #[test (1+2)*3, 9] -// Error: 1:3-1:3 expected expression +// Error: 3-3 expected expression {-} -// Error: 1:11-1:11 expected expression +// Error: 11-11 expected expression #[test {1+}, 1] -// Error: 1:11-1:11 expected expression +// Error: 11-11 expected expression #[test {2*}, 2] -// Error: 1:8-1:17 cannot apply '-' to boolean +// Error: 8-17 cannot apply '-' to boolean #[test -not true, error] -// Error: 1:2-1:8 cannot apply 'not' to array +// Error: 2-8 cannot apply 'not' to array {not ()} -// Error: 1:3-1:10 cannot apply '+' to integer and string +// Error: 3-10 cannot apply '+' to integer and string {(1 + "2")} -// Error: 1:2-1:12 cannot apply '<=' to relative and relative +// Error: 2-12 cannot apply '<=' to relative and relative {30% <= 40%} diff --git a/tests/lang/typ/headings.typ b/tests/lang/typ/headings.typ index a1bb37537..2fd2d2aca 100644 --- a/tests/lang/typ/headings.typ +++ b/tests/lang/typ/headings.typ @@ -6,7 +6,7 @@ ====== Six // Too many hashtags. -// Warning: 1:1-1:8 should not exceed depth 6 +// Warning: 1-8 should not exceed depth 6 ======= Seven --- diff --git a/tests/lang/typ/if.typ b/tests/lang/typ/if.typ index 5fb46320b..0e0d03d17 100644 --- a/tests/lang/typ/if.typ +++ b/tests/lang/typ/if.typ @@ -39,7 +39,7 @@ a#if true {"b"} #else {"?"} c \ #let x = true // Needs condition. -// Error: 1:6-1:7 expected expression, found closing brace +// Error: 6-7 expected expression, found closing brace a#if } // Needs if-body. @@ -48,17 +48,17 @@ a#if } a#if x b#if (x)c // Needs else-body. -// Error: 1:20-1:20 expected body +// Error: 20-20 expected body a#if true [b] #else c // Lone else. -// Error: 1:1-1:6 unexpected keyword `#else` +// Error: 1-6 unexpected keyword `#else` #else [] // Condition must be boolean. If it isn't, neither branch is evaluated. -// Error: 1:5-1:14 expected boolean, found string +// Error: 5-14 expected boolean, found string #if "a" + "b" { "nope" } #else { "nope" } // No coercing from empty array or or stuff like that. -// Error: 1:5-1:7 expected boolean, found array +// Error: 5-7 expected boolean, found array #if () { "nope" } #else { "nope" } diff --git a/tests/lang/typ/let.typ b/tests/lang/typ/let.typ index 52545b2f0..4f42e44c6 100644 --- a/tests/lang/typ/let.typ +++ b/tests/lang/typ/let.typ @@ -21,24 +21,24 @@ #let x = "a"; #let y = "b"; #[test x + y, "ab"] // Invalid name. -// Error: 1:6-1:7 expected identifier, found integer +// Error: 6-7 expected identifier, found integer #let 1 // Invalid name. -// Error: 1:6-1:7 expected identifier, found integer +// Error: 6-7 expected identifier, found integer #let 1 = 2 // Missing binding name. -// Error: 1:5-1:5 expected identifier +// Error: 5-5 expected identifier #let x = 5 // Missing right-hand side. -// Error: 1:9-1:9 expected expression +// Error: 9-9 expected expression #let a = // No name at all. -// Error: 1:11-1:11 expected identifier +// Error: 11-11 expected identifier The Fi#let;rst // Terminated with just a line break. @@ -58,9 +58,9 @@ The#let v = "a"; Fourth #[test v, "a"] The#let array = (1, 2 + ;Fifth #[test array, (1, 2)] // Not terminated. -// Error: 1:16-1:16 expected semicolon or line break +// Error: 16-16 expected semicolon or line break The#let v = "a"Sixth #[test v, "a"] // Not terminated. -// Error: 1:16-1:16 expected semicolon or line break +// Error: 16-16 expected semicolon or line break The#let v = "a" #[test v, "a"] Seventh diff --git a/tests/lang/typ/values.typ b/tests/lang/typ/values.typ index 53c2ea68c..7260cad10 100644 --- a/tests/lang/typ/values.typ +++ b/tests/lang/typ/values.typ @@ -9,7 +9,7 @@ {ke-bab} \ {α} \ -// Error: 1:2-1:3 unknown variable +// Error: 2-3 unknown variable {_} // Literal values. diff --git a/tests/library/typ/font.typ b/tests/library/typ/font.typ index 57761a8fb..1bfc1fa65 100644 --- a/tests/library/typ/font.typ +++ b/tests/library/typ/font.typ @@ -19,7 +19,7 @@ // Set stretch (not available, matching closest). #[font stretch: ultra-condensed][Condensed] -// Error: 1:8-1:13 unexpected argument +// Error: 8-13 unexpected argument #[font false] // Error: 3:15-3:19 expected font style, found font weight @@ -27,10 +27,10 @@ // Error: 1:44-1:45 expected font family or array of font families, found integer #[font style: bold, weight: "thin", serif: 0] -// Warning: 1:16-1:20 should be between 100 and 900 +// Warning: 16-20 should be between 100 and 900 #[font weight: 2700] -// Error: 1:8-1:28 unexpected argument +// Error: 8-28 unexpected argument #[font something: "invalid"] --- diff --git a/tests/library/typ/hv.typ b/tests/library/typ/hv.typ index 67c04a12f..15799c811 100644 --- a/tests/library/typ/hv.typ +++ b/tests/library/typ/hv.typ @@ -11,7 +11,7 @@ Add #[h 10pt] #[h 10pt] up Relative #[h 100%] spacing // Missing spacing. -// Error: 1:12-1:12 missing argument: spacing +// Error: 12-12 missing argument: spacing Totally #[h] ignored // Swapped axes. diff --git a/tests/library/typ/image.typ b/tests/library/typ/image.typ index a1e886dd9..ced364b36 100644 --- a/tests/library/typ/image.typ +++ b/tests/library/typ/image.typ @@ -7,10 +7,10 @@ // Load an RGB JPEG image. #[image "res/tiger.jpg"] -// Error: 1:9-1:30 failed to load image +// Error: 9-30 failed to load image #[image "path/does/not/exist"] -// Error: 1:9-1:30 failed to load image +// Error: 9-30 failed to load image #[image "typ/image-error.typ"] --- diff --git a/tests/library/typ/page.typ b/tests/library/typ/page.typ index 97100ae99..8a9604ad5 100644 --- a/tests/library/typ/page.typ +++ b/tests/library/typ/page.typ @@ -21,10 +21,10 @@ // Ensure that specific margins override general margins. #[page margins: 0pt, left: 20pt][Overriden] -// Error: 1:8-1:19 unknown variable +// Error: 8-19 unknown variable #[page nonexistant] -// Error: 1:18-1:21 aligned axis +// Error: 18-21 aligned axis #[page main-dir: ltr] // Flipped predefined paper. diff --git a/tests/library/typ/rgb.typ b/tests/library/typ/rgb.typ index e7b405184..06f7be52e 100644 --- a/tests/library/typ/rgb.typ +++ b/tests/library/typ/rgb.typ @@ -8,7 +8,7 @@ // Warning: 1:12-1:16 should be between 0.0 and 1.0 #[rgb -30, 15.5, 0.5] -// Error: 1:7-1:11 missing argument: blue component +// Error: 7-11 missing argument: blue component #[rgb 0, 1] // Error: 3:6-3:6 missing argument: red component diff --git a/tests/typeset.rs b/tests/typeset.rs index 4b9d26a47..76436ae84 100644 --- a/tests/typeset.rs +++ b/tests/typeset.rs @@ -262,7 +262,9 @@ fn parse_metadata(src: &str, map: &LineMap) -> (bool, SpanVec) { } let pos = |s: &mut Scanner| -> Pos { - let (delta, _, column) = (num(s), s.eat_assert(':'), num(s)); + let first = num(s); + let (delta, column) = + if s.eat_if(':') { (first, num(s)) } else { (1, first) }; let line = i as u32 + 1 + delta; map.pos(Location::new(line, column)).unwrap() };