aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/c.zig
diff options
context:
space:
mode:
authorJacob Young <jacobly0@users.noreply.github.com>2022-11-01 03:31:20 -0400
committerJacob Young <jacobly0@users.noreply.github.com>2022-11-01 20:39:05 -0400
commit071404ff6500d26c3f8c5b08645bd90ebb3a901b (patch)
treedc30280256197634a6b974f55d5dc4d7e06366bb /src/codegen/c.zig
parent8e52be1602f0b7953332d2e5e9a2b6f23e5410ce (diff)
downloadzig-071404ff6500d26c3f8c5b08645bd90ebb3a901b.tar.gz
zig-071404ff6500d26c3f8c5b08645bd90ebb3a901b.zip
cbe: fix optional access
Diffstat (limited to 'src/codegen/c.zig')
-rw-r--r--src/codegen/c.zig6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/codegen/c.zig b/src/codegen/c.zig
index 269383884d..d54ef6b660 100644
--- a/src/codegen/c.zig
+++ b/src/codegen/c.zig
@@ -3193,7 +3193,7 @@ fn airEquality(
try writer.writeAll(" = ");
- if (operand_ty.tag() == .optional) {
+ if (operand_ty.zigTypeTag() == .Optional and !operand_ty.isPtrLikeOptional()) {
// (A && B) || (C && (A == B))
// A = lhs.is_null ; B = rhs.is_null ; C = rhs.payload == lhs.payload
@@ -3984,9 +3984,9 @@ fn airIsNull(
const rhs = if (!payload_ty.hasRuntimeBitsIgnoreComptime())
TypedValue{ .ty = Type.bool, .val = Value.@"true" }
- else if (operand_ty.isPtrLikeOptional())
+ else if (optional_ty.isPtrLikeOptional())
// operand is a regular pointer, test `operand !=/== NULL`
- TypedValue{ .ty = operand_ty, .val = Value.@"null" }
+ TypedValue{ .ty = optional_ty, .val = Value.@"null" }
else if (payload_ty.zigTypeTag() == .ErrorSet)
TypedValue{ .ty = payload_ty, .val = Value.zero }
else if (payload_ty.isSlice() and optional_ty.optionalReprIsPayload()) rhs: {