mirror of
https://github.com/PixelGuys/Cubyz.git
synced 2025-09-10 04:41:32 -04:00
zon: Improve the duplicate key error
This commit is contained in:
parent
b660a26b19
commit
1c64a8e4b7
@ -631,6 +631,7 @@ const Parser = struct { // MARK: Parser
|
|||||||
return .{.object = map};
|
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.
|
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);
|
const key: []const u8 = parseIdentifierOrStringOrEnumLiteral(allocator, chars, index);
|
||||||
skipWhitespaces(chars, index);
|
skipWhitespaces(chars, index);
|
||||||
while(index.* < chars.len and chars[index.*] != '=') {
|
while(index.* < chars.len and chars[index.*] != '=') {
|
||||||
@ -641,7 +642,7 @@ const Parser = struct { // MARK: Parser
|
|||||||
skipWhitespaces(chars, index);
|
skipWhitespaces(chars, index);
|
||||||
const value: ZonElement = parseElement(allocator, chars, index);
|
const value: ZonElement = parseElement(allocator, chars, index);
|
||||||
if(map.fetchPut(key, value) catch unreachable) |old| {
|
if(map.fetchPut(key, value) catch unreachable) |old| {
|
||||||
printError(chars, index.*, "Duplicate key.");
|
printError(chars, keyIndex, "Duplicate key.");
|
||||||
allocator.free(old.key);
|
allocator.free(old.key);
|
||||||
old.value.deinit(allocator);
|
old.value.deinit(allocator);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user