diff options
| author | tgschultz <tgschultz@gmail.com> | 2018-08-25 10:51:49 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-08-25 10:51:49 -0500 |
| commit | 61c0c6d502b19a6aa232d91a201eba9d67aced5a (patch) | |
| tree | 2d5535b402165f0d664c0765ef1a5105fe45a11a /std | |
| parent | 4003cd4747019d79ff50aaa22415d2d3dfc15cf4 (diff) | |
| download | zig-61c0c6d502b19a6aa232d91a201eba9d67aced5a.tar.gz zig-61c0c6d502b19a6aa232d91a201eba9d67aced5a.zip | |
Fixed compile error when passing enum to fmt
Caused by struct printing behavior. Enums are different enough from structs and unions that the field iteration behavior doesn't do what we want even if @memberName didn't error on enums.
Diffstat (limited to 'std')
| -rw-r--r-- | std/fmt/index.zig | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/std/fmt/index.zig b/std/fmt/index.zig index 812f5e72cd..a3d2344740 100644 --- a/std/fmt/index.zig +++ b/std/fmt/index.zig @@ -166,6 +166,11 @@ pub fn formatType( if (has_cust_fmt) return value.format(fmt, context, Errors, output); try output(context, @typeName(T)); + if (comptime @typeId(T) == builtin.TypeId.Enum) { + try output(context, "."); + try formatType(@tagName(value), "", context, Errors, output); + return; + } comptime var field_i = 0; inline while (field_i < @memberCount(T)) : (field_i += 1) { if (field_i == 0) { |
