CBE: fix union init wrong field name

This commit is contained in:
Andrew Kelley 2022-12-03 19:41:35 -07:00
parent aa98517b3e
commit 701cebeb30

View File

@ -6436,10 +6436,15 @@ fn airUnionInit(f: *Function, inst: Air.Inst.Index) !CValue {
try f.writeCValue(writer, local, .Other);
try writer.print(".tag = {}; ", .{try f.fmtIntLiteral(tag_ty, int_val)});
}
try f.writeCValue(writer, local, .Other);
try writer.print(".payload.{ } = ", .{fmtIdent(field_name)});
try f.writeCValue(writer, payload, .Other);
try writer.writeAll(";\n");
return local;
}
try f.writeCValue(writer, local, .Other);
try writer.print(".payload.{ } = ", .{fmtIdent(field_name)});
try writer.print(".{ } = ", .{fmtIdent(field_name)});
try f.writeCValue(writer, payload, .Other);
try writer.writeAll(";\n");