diff options
| author | Jacob Young <jacobly0@users.noreply.github.com> | 2023-06-25 18:50:58 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-06-26 01:30:00 -0700 |
| commit | c036f83fa0f029e8e03e599f5b9e95cf98224a1c (patch) | |
| tree | e187b0edca116f386992449434456193d083e671 /src/value.zig | |
| parent | cc2daae47e4fbb7d68e00211d509dd934d2e14b2 (diff) | |
| download | zig-c036f83fa0f029e8e03e599f5b9e95cf98224a1c.tar.gz zig-c036f83fa0f029e8e03e599f5b9e95cf98224a1c.zip | |
Value: fix incorrect types returned from readFromMemory
Diffstat (limited to 'src/value.zig')
| -rw-r--r-- | src/value.zig | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/value.zig b/src/value.zig index 1c22717152..6b85ebd552 100644 --- a/src/value.zig +++ b/src/value.zig @@ -946,12 +946,24 @@ pub const Value = struct { }, .Pointer => { assert(!ty.isSlice(mod)); // No well defined layout. - return readFromMemory(Type.usize, mod, buffer, arena); + const int_val = try readFromMemory(Type.usize, mod, buffer, arena); + return (try mod.intern(.{ .ptr = .{ + .ty = ty.toIntern(), + .addr = .{ .int = int_val.toIntern() }, + } })).toValue(); }, .Optional => { assert(ty.isPtrLikeOptional(mod)); - const child = ty.optionalChild(mod); - return readFromMemory(child, mod, buffer, arena); + const child_ty = ty.optionalChild(mod); + const child_val = try readFromMemory(child_ty, mod, buffer, arena); + return (try mod.intern(.{ .opt = .{ + .ty = ty.toIntern(), + .val = switch (child_val.orderAgainstZero(mod)) { + .lt => unreachable, + .eq => .none, + .gt => child_val.toIntern(), + }, + } })).toValue(); }, else => @panic("TODO implement readFromMemory for more types"), } |
