Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
July 06, 2013 [Issue 10555] New: enumerator can no longer increment beyond maximum of initializer | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=10555 Summary: enumerator can no longer increment beyond maximum of initializer Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: regression Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: r.sagitario@gmx.de --- Comment #0 from Rainer Schuetze <r.sagitario@gmx.de> 2013-07-06 06:03:46 PDT --- I'm not sure if the new behaviour in git HEAD is desired or not, but this code used to compile until one or two weeks ago: enum A { A0 } enum B { B0 = A.A0, B1 } Now it errors out with Error: enum test.B overflow of enum value cast(B)cast(A)0 because dmd does not want to increment A0. More strange things: //////////////////////// enum A { A0 } enum B { B0 = A.A0, B1 = A.A0 + 1 } Error: cannot implicitly convert expression (1) of type int to A though this works enum A { A0 } enum B { B0 = A.A0 + 0, B1 } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
July 10, 2013 [Issue 10555] enumerator can no longer increment beyond maximum of initializer | ||||
---|---|---|---|---|
| ||||
Posted in reply to Rainer Schuetze | http://d.puremagic.com/issues/show_bug.cgi?id=10555 Andrej Mitrovic <andrej.mitrovich@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrej.mitrovich@gmail.com --- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-07-10 08:16:59 PDT --- Well if anything, the recent enum fixes and subsequent regressions exposed that we have a really poor enum test-suite. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 30, 2013 [Issue 10555] enumerator can no longer increment beyond maximum of initializer | ||||
---|---|---|---|---|
| ||||
Posted in reply to Rainer Schuetze | http://d.puremagic.com/issues/show_bug.cgi?id=10555 hsteoh@quickfur.ath.cx changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |hsteoh@quickfur.ath.cx --- Comment #2 from hsteoh@quickfur.ath.cx 2013-08-30 11:02:19 PDT --- git bisect shows that the offending commit was 88ebe192d605bd8d4b5768e8a2500f54d73fb5fd - fix issue 3096 - EnumBaseType -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 31, 2013 [Issue 10555] enumerator can no longer increment beyond maximum of initializer | ||||
---|---|---|---|---|
| ||||
Posted in reply to Rainer Schuetze | http://d.puremagic.com/issues/show_bug.cgi?id=10555 Henning Pohl <henning@still-hidden.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |henning@still-hidden.de --- Comment #3 from Henning Pohl <henning@still-hidden.de> 2013-08-31 04:16:03 PDT --- I think this behaviour is correct: Spec: ---- If the EnumBaseType is not explicitly set, and the first EnumMember has an initializer, it is set to the type of that initializer. Otherwise, it defaults to type int. Named enum members may not have individual Types. A named enum member can be implicitly cast to its EnumBaseType, but EnumBaseType types cannot be implicitly cast to an enum type. ---- The behaviour before issue 3096 always used int as EnumBaseType even though there is a first initializer. enum A // int { A0 } enum B // A { B0 = A.A0, B1 } In this case the base type of B is A and A does not have a member whith a value of 1. enum A // int { A0 } enum B // A { B0 = A.A0, B1 = A.A0 + 1 } This is basically the same case as above. enum A // int { A0 } enum B // int { B0 = A.A0 + 0, B1 } This works because the type of the first initializer is int. So the base type of B becomes int and ints can be incremented easily. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 31, 2013 [Issue 10555] enumerator can no longer increment beyond maximum of initializer | ||||
---|---|---|---|---|
| ||||
Posted in reply to Rainer Schuetze | http://d.puremagic.com/issues/show_bug.cgi?id=10555 --- Comment #4 from Henning Pohl <henning@still-hidden.de> 2013-08-31 04:23:52 PDT --- Keep in mind that you can always cast to the base type: enum A // int { A0 } template BaseType(E) { static if (is(E e == enum)) { alias BaseType = e; } else { static assert("not an enum"); } } enum B // int { B0 = cast(BaseType!A)A.A0, B1 } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 02, 2013 [Issue 10555] enumerator can no longer increment beyond maximum of initializer | ||||
---|---|---|---|---|
| ||||
Posted in reply to Rainer Schuetze | http://d.puremagic.com/issues/show_bug.cgi?id=10555 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID --- Comment #5 from Kenji Hara <k.hara.pg@gmail.com> 2013-10-01 23:13:04 PDT --- I agree with Henning Pohl. The behavior in 2.063/earlier was an accepts-invalid bug, and it has been correctly fixed in git-head. -- 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