aboutsummaryrefslogtreecommitdiff
path: root/std
diff options
context:
space:
mode:
authorLemonBoy <thatlemon@gmail.com>2019-04-19 19:59:14 +0200
committerLemonBoy <thatlemon@gmail.com>2019-04-19 19:59:14 +0200
commit0286be127e4b9f74ddffcc241b947c7c5bb3dfce (patch)
treedb1a925176f8aff0125ff884a1099d89929cf279 /std
parent3b6a4fe4cd0800b7078953d56156475f699751f1 (diff)
downloadzig-0286be127e4b9f74ddffcc241b947c7c5bb3dfce.tar.gz
zig-0286be127e4b9f74ddffcc241b947c7c5bb3dfce.zip
Fix parseFormValueConstant
Signed/unsigned confusion made the code fail an assertion sometimes.
Diffstat (limited to 'std')
-rw-r--r--std/debug.zig7
1 files changed, 4 insertions, 3 deletions
diff --git a/std/debug.zig b/std/debug.zig
index 90b4ff31d5..b360601e92 100644
--- a/std/debug.zig
+++ b/std/debug.zig
@@ -1440,7 +1440,7 @@ fn parseFormValueBlock(allocator: *mem.Allocator, in_stream: var, size: usize) !
return parseFormValueBlockLen(allocator, in_stream, block_len);
}
-fn parseFormValueConstant(allocator: *mem.Allocator, in_stream: var, signed: bool, size: i32) !FormValue {
+fn parseFormValueConstant(allocator: *mem.Allocator, in_stream: var, signed: bool, comptime size: i32) !FormValue {
return FormValue{
.Const = Constant{
.signed = signed,
@@ -1449,8 +1449,9 @@ fn parseFormValueConstant(allocator: *mem.Allocator, in_stream: var, signed: boo
2 => try in_stream.readIntLittle(u16),
4 => try in_stream.readIntLittle(u32),
8 => try in_stream.readIntLittle(u64),
- -1 => if (signed) try readULeb128(in_stream) else @intCast(u64, try readILeb128(in_stream)),
- else => unreachable,
+ -1 => if (signed) @intCast(u64, try readILeb128(in_stream))
+ else try readULeb128(in_stream),
+ else => @compileError("Invalid size"),
},
},
};