protocols
This commit is contained in:
@@ -6078,8 +6078,16 @@ pub const CodeGen = struct {
|
||||
// xx prefix: unwrap and convert freely (explicit cast)
|
||||
if (node.data == .unary_op and node.data.unary_op.op == .xx) {
|
||||
const inner = node.data.unary_op.operand;
|
||||
const val = try self.genExpr(inner);
|
||||
var val = try self.genExpr(inner);
|
||||
const src_ty = self.inferType(inner);
|
||||
// genExpr on struct literals returns an alloca (ptr), not a loaded value.
|
||||
// Load it so convertValue/buildProtocolValue sees the actual struct value.
|
||||
if (inner.data == .struct_literal and src_ty.isStruct()) {
|
||||
const sname = self.resolveAlias(src_ty.struct_type);
|
||||
if (self.lookupStructInfo(sname)) |si| {
|
||||
val = c.LLVMBuildLoad2(self.builder, si.llvm_type.?, val, "xx_struct_load");
|
||||
}
|
||||
}
|
||||
return self.convertValue(val, src_ty, target_ty);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user