From 1c64a8e4b7988a17b8d5ddc758d047fc3aaa84d3 Mon Sep 17 00:00:00 2001 From: IntegratedQuantum Date: Fri, 28 Feb 2025 18:38:50 +0100 Subject: [PATCH] zon: Improve the duplicate key error --- src/zon.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/zon.zig b/src/zon.zig index 40aee9dc..24fdfbad 100644 --- a/src/zon.zig +++ b/src/zon.zig @@ -631,6 +631,7 @@ const Parser = struct { // MARK: Parser return .{.object = map}; } if(chars[index.*] == '.') index.* += 1; // Just ignoring the dot in front of identifiers, the file might as well not have for all I care. + const keyIndex = index.*; const key: []const u8 = parseIdentifierOrStringOrEnumLiteral(allocator, chars, index); skipWhitespaces(chars, index); while(index.* < chars.len and chars[index.*] != '=') { @@ -641,7 +642,7 @@ const Parser = struct { // MARK: Parser skipWhitespaces(chars, index); const value: ZonElement = parseElement(allocator, chars, index); if(map.fetchPut(key, value) catch unreachable) |old| { - printError(chars, index.*, "Duplicate key."); + printError(chars, keyIndex, "Duplicate key."); allocator.free(old.key); old.value.deinit(allocator); }