mirror of
https://github.com/ziglang/zig.git
synced 2025-02-16 09:30:17 +00:00
removed .string and .allocated_string from inner_parse when parsing numbers
Now returns an error UnexpectedToken
This commit is contained in:
parent
a7792b4563
commit
8cfb9239e7
@ -230,7 +230,7 @@ pub fn innerParse(
|
|||||||
const token = try source.nextAllocMax(allocator, .alloc_if_needed, options.max_value_len.?);
|
const token = try source.nextAllocMax(allocator, .alloc_if_needed, options.max_value_len.?);
|
||||||
defer freeAllocated(allocator, token);
|
defer freeAllocated(allocator, token);
|
||||||
const slice = switch (token) {
|
const slice = switch (token) {
|
||||||
inline .number, .allocated_number, .string, .allocated_string => |slice| slice,
|
inline .number, .allocated_number => |slice| slice,
|
||||||
else => return error.UnexpectedToken,
|
else => return error.UnexpectedToken,
|
||||||
};
|
};
|
||||||
return try std.fmt.parseFloat(T, slice);
|
return try std.fmt.parseFloat(T, slice);
|
||||||
@ -240,7 +240,6 @@ pub fn innerParse(
|
|||||||
defer freeAllocated(allocator, token);
|
defer freeAllocated(allocator, token);
|
||||||
const slice = switch (token) {
|
const slice = switch (token) {
|
||||||
inline .number, .allocated_number => |slice| slice,
|
inline .number, .allocated_number => |slice| slice,
|
||||||
.string, .allocated_string => return error.UnexpectedToken,
|
|
||||||
else => return error.UnexpectedToken,
|
else => return error.UnexpectedToken,
|
||||||
};
|
};
|
||||||
return sliceToInt(T, slice);
|
return sliceToInt(T, slice);
|
||||||
|
Loading…
Reference in New Issue
Block a user