April 06, 2005 writef and enum (Error: std.format formatArg) | ||||
---|---|---|---|---|
| ||||
This has to be an old, or known bug, but a quick search found nothing... import std.stdio; enum FOO : int { A, B, C } void main() { FOO a = FOO.A; writefln(a); writefln("%d",a); } neither writefln works. Both give "Error: std.format formatArg". Note the enum is typed, it doesn't seem to matter whether it is or not. A quick un-educated peek in doFormat shows no switch case for enums, so unless they're classified as ints? Regan |
April 06, 2005 Re: writef and enum (Error: std.format formatArg) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Regan Heath | Regan Heath wrote: > This has to be an old, or known bug, but a quick search found nothing... > > import std.stdio; > > enum FOO : int { A, B, C } > > void main() > { > FOO a = FOO.A; > writefln(a); > writefln("%d",a); > } > > neither writefln works. Both give "Error: std.format formatArg". Note the enum is typed, it doesn't seem to matter whether it is or not. A quick un-educated peek in doFormat shows no switch case for enums, so unless they're classified as ints? Clearly the TypeInfo for enums is still not properly implemented. But if using %d, it certainly ought to just output the numerical value. AIUI, the plan for %s (or no active format string) on enums is to have it output the enum constant name. But it isn't clear what it should do if there's no matching constant (as with a set of bit flags) or more than one. Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit. |
Copyright © 1999-2021 by the D Language Foundation