| ... | ... | @@ -365,14 +365,21 @@ pub fn formatType( |
| 365 | 365 | try output(context, "error."); |
| 366 | 366 | return output(context, @errorName(value)); |
| 367 | 367 | }, |
| 368 | | .Enum => { |
| 368 | .Enum => |enumInfo| { |
| 369 | 369 | if (comptime std.meta.trait.hasFn("format")(T)) { |
| 370 | 370 | return value.format(fmt, options, context, Errors, output); |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | try output(context, @typeName(T)); |
| 374 | | try output(context, "."); |
| 375 | | return formatType(@tagName(value), "", options, context, Errors, output, max_depth); |
| 374 | if (enumInfo.is_exhaustive) { |
| 375 | try output(context, "."); |
| 376 | return formatType(@tagName(value), "", options, context, Errors, output, max_depth); |
| 377 | } else { |
| 378 | // TODO: when @tagName works on exhaustive enums print known enum strings |
| 379 | try output(context, "("); |
| 380 | try formatType(@enumToInt(value), "", options, context, Errors, output, max_depth); |
| 381 | try output(context, ")"); |
| 382 | } |
| 376 | 383 | }, |
| 377 | 384 | .Union => { |
| 378 | 385 | if (comptime std.meta.trait.hasFn("format")(T)) { |