From 5f9b9c564c7dfc2c0424afd4119ddc4628231e95 Mon Sep 17 00:00:00 2001 From: Auguste Rame Date: Sun, 17 Jul 2022 16:29:03 +0200 Subject: [PATCH] Fix tokenRelativeLocation Closes #354 Closes #543 --- src/offsets.zig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/offsets.zig b/src/offsets.zig index ea1d2d9..a6446c2 100644 --- a/src/offsets.zig +++ b/src/offsets.zig @@ -104,7 +104,9 @@ pub const TokenLocation = struct { }; pub fn tokenRelativeLocation(tree: Ast, start_index: usize, token_start: usize, encoding: Encoding) !TokenLocation { - std.debug.assert(token_start >= start_index); + if (token_start < start_index) + return error.InvalidParams; + var loc = TokenLocation{ .line = 0, .column = 0,