Skip to content

Commit 2a75b3b

Browse files
authored
Merge pull request microsoft#524 from hkrutzer/fix-underflow
fix: Integer underflow in lexer error message formatting
2 parents d4b7d1f + 3962b3c commit 2a75b3b

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

src/lexer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ impl Source {
203203

204204
let line_str = format!("{line}");
205205
let line_num_width = line_str.len() + 1;
206-
let col_spaces = col as usize - 1;
206+
let col_spaces = (col as usize).saturating_sub(1);
207207

208208
format!(
209209
"\n--> {}:{}:{}\n{:<line_num_width$}|\n\

tests/interpreter/cases/call/basic.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,13 @@ cases:
7575
}
7676
query: data.test
7777
error: expects numeric argument.
78-
78+
79+
- note: multiline-member-access-should-error
80+
data: {}
81+
modules:
82+
- |
83+
package test
84+
output := regex.
85+
match("^a", "b")
86+
query: data.test
87+
error: invalid whitespace between . and identifier

0 commit comments

Comments
 (0)