| author | |
| committer | |
| log | 22432b15e31d506d070171b2932d5df71e9a1b9e |
| tree | 9562bb32559ea9554c3866e4a26e2475b71058df |
| parent | 215797749d0e0d911feaaf45dc70836c3d12f18e |
| signature |
3 files changed, 14 insertions(+), 5 deletions(-)
lib/std/fmt.zig+2-4| ... | @@ -414,10 +414,9 @@ pub fn formatType( | ... | @@ -414,10 +414,9 @@ pub fn formatType( |
| 414 | if (max_depth == 0) { | 414 | if (max_depth == 0) { |
| 415 | return output(context, "{ ... }"); | 415 | return output(context, "{ ... }"); |
| 416 | } | 416 | } |
| 417 | comptime var field_i = 0; | ||
| 418 | try output(context, "{"); | 417 | try output(context, "{"); |
| 419 | inline for (StructT.fields) |f| { | 418 | inline for (StructT.fields) |f, i| { |
| 420 | if (field_i == 0) { | 419 | if (i == 0) { |
| 421 | try output(context, " ."); | 420 | try output(context, " ."); |
| 422 | } else { | 421 | } else { |
| 423 | try output(context, ", ."); | 422 | try output(context, ", ."); |
| ... | @@ -425,7 +424,6 @@ pub fn formatType( | ... | @@ -425,7 +424,6 @@ pub fn formatType( |
| 425 | try output(context, f.name); | 424 | try output(context, f.name); |
| 426 | try output(context, " = "); | 425 | try output(context, " = "); |
| 427 | try formatType(@field(value, f.name), fmt, options, context, Errors, output, max_depth - 1); | 426 | try formatType(@field(value, f.name), fmt, options, context, Errors, output, max_depth - 1); |
| 428 | field_i += 1; | ||
| 429 | } | 427 | } |
| 430 | try output(context, " }"); | 428 | try output(context, " }"); |
| 431 | }, | 429 | }, |
src-self-hosted/ir.zig+1-1| ... | @@ -1803,7 +1803,7 @@ pub const Builder = struct { | ... | @@ -1803,7 +1803,7 @@ pub const Builder = struct { |
| 1803 | 1803 | ||
| 1804 | // Look at the params and ref() other instructions | 1804 | // Look at the params and ref() other instructions |
| 1805 | inline for (@typeInfo(I.Params).Struct.fields) |f| { | 1805 | inline for (@typeInfo(I.Params).Struct.fields) |f| { |
| 1806 | switch (f.fiedl_type) { | 1806 | switch (f.field_type) { |
| 1807 | *Inst => @field(inst.params, f.name).ref(self), | 1807 | *Inst => @field(inst.params, f.name).ref(self), |
| 1808 | *BasicBlock => @field(inst.params, f.name).ref(self), | 1808 | *BasicBlock => @field(inst.params, f.name).ref(self), |
| 1809 | ?*Inst => if (@field(inst.params, f.name)) |other| other.ref(self), | 1809 | ?*Inst => if (@field(inst.params, f.name)) |other| other.ref(self), |
test/stage1/behavior/cast.zig+11| ... | @@ -491,6 +491,17 @@ test "@intToEnum passed a comptime_int to an enum with one item" { | ... | @@ -491,6 +491,17 @@ test "@intToEnum passed a comptime_int to an enum with one item" { |
| 491 | expect(x == E.A); | 491 | expect(x == E.A); |
| 492 | } | 492 | } |
| 493 | 493 | ||
| 494 | test "@intToEnum runtime to an extern enum with duplicate values" { | ||
| 495 | const E = extern enum(u8) { | ||
| 496 | A = 1, | ||
| 497 | B = 1, | ||
| 498 | }; | ||
| 499 | var a: u8 = 1; | ||
| 500 | var x = @intToEnum(E, a); | ||
| 501 | expect(x == E.A); | ||
| 502 | expect(x == E.B); | ||
| 503 | } | ||
| 504 | |||
| 494 | test "@intCast to u0 and use the result" { | 505 | test "@intCast to u0 and use the result" { |
| 495 | const S = struct { | 506 | const S = struct { |
| 496 | fn doTheTest(zero: u1, one: u1, bigzero: i32) void { | 507 | fn doTheTest(zero: u1, one: u1, bigzero: i32) void { |