Commit 22432b15e3
lib/std/fmt.zig
@@ -414,10 +414,9 @@ pub fn formatType(
if (max_depth == 0) {
return output(context, "{ ... }");
}
- comptime var field_i = 0;
try output(context, "{");
- inline for (StructT.fields) |f| {
- if (field_i == 0) {
+ inline for (StructT.fields) |f, i| {
+ if (i == 0) {
try output(context, " .");
} else {
try output(context, ", .");
@@ -425,7 +424,6 @@ pub fn formatType(
try output(context, f.name);
try output(context, " = ");
try formatType(@field(value, f.name), fmt, options, context, Errors, output, max_depth - 1);
- field_i += 1;
}
try output(context, " }");
},
src-self-hosted/ir.zig
@@ -1803,7 +1803,7 @@ pub const Builder = struct {
// Look at the params and ref() other instructions
inline for (@typeInfo(I.Params).Struct.fields) |f| {
- switch (f.fiedl_type) {
+ switch (f.field_type) {
*Inst => @field(inst.params, f.name).ref(self),
*BasicBlock => @field(inst.params, f.name).ref(self),
?*Inst => if (@field(inst.params, f.name)) |other| other.ref(self),
test/stage1/behavior/cast.zig
@@ -491,6 +491,17 @@ test "@intToEnum passed a comptime_int to an enum with one item" {
expect(x == E.A);
}
+test "@intToEnum runtime to an extern enum with duplicate values" {
+ const E = extern enum(u8) {
+ A = 1,
+ B = 1,
+ };
+ var a: u8 = 1;
+ var x = @intToEnum(E, a);
+ expect(x == E.A);
+ expect(x == E.B);
+}
+
test "@intCast to u0 and use the result" {
const S = struct {
fn doTheTest(zero: u1, one: u1, bigzero: i32) void {