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.
This commit is contained in:
tgschultz 2018-08-25 10:51:49 -05:00 committed by GitHub
parent 4003cd4747
commit 61c0c6d502
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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) {