February 09, 2012 [Issue 7477] New: Enum structs without specified values | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=7477 Summary: Enum structs without specified values Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: clugdbug@yahoo.com.au --- Comment #0 from Don <clugdbug@yahoo.com.au> 2012-02-09 14:00:35 PST --- Bug 4423 considers the case of enum structs where all values are explicitly specified; it requires a particular opCmp signature. The case of enum structs when values are NOT specified is even more problematic. struct Foo { int x; } enum Bar : Foo { a, b } For this to work, it is required that Foo supports: * implicit cast from 0 to Foo. * a .max property * + 1 * and opCmp of the correct signature. I think this is a useless feature, and should simply be dropped. Currently, the test case gives some unhelpful error messages, containing __error and no line number: crash.d(3): Error: cannot implicitly convert expression (0) of type int to Foo66 99 Error: no property 'max' for type 'Foo6699' crash.d(3): Error: Integer constant expression expected instead of (__error) == (__error) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 09, 2012 [Issue 7477] Enum structs without specified values | ||||
---|---|---|---|---|
| ||||
Posted in reply to Don | http://d.puremagic.com/issues/show_bug.cgi?id=7477 Jonathan M Davis <jmdavisProg@gmx.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jmdavisProg@gmx.com --- Comment #1 from Jonathan M Davis <jmdavisProg@gmx.com> 2012-02-09 14:16:33 PST --- The same thing happens if you do something like enum Foo : string { a, b } q.d(3): Error: cannot implicitly convert expression (0) of type int to string Error: no property 'max' for type 'string' q.d(3): Error: Integer constant expression expected instead of (__error) == (__error) So, it's not really struct-specific. It affects all types which can't be implicitly assigned 0. It would probably be simplest to require that enums must either be values or they must be primitive types other than arrays, or maybe outright require that they be integral values (I question the usefulness of using bool or floating point enums without specifying their values). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation