Thread overview
[Issue 2414] New: enum is dynamically evaluated, yum
Oct 12, 2008
d-bugmail
Oct 12, 2008
d-bugmail
Oct 17, 2008
Bruno Medeiros
Jun 19, 2011
Kenji Hara
Jun 19, 2011
kennytm@gmail.com
October 12, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2414

           Summary: enum is dynamically evaluated, yum
           Product: D
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: andrei@metalanguage.com


Just compile this, run it, and have a laugh:

import std.stdio;

void main()
{
    double a = 1, b = 2;
    enum c = a + b;
    writeln(c);
    a = 2, b = 3;
    writeln(c);
}


-- 

October 12, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2414





------- Comment #1 from jarrett.billingsley@gmail.com  2008-10-12 15:36 -------
It's a macro!  Weee!


-- 

October 17, 2008
d-bugmail@puremagic.com wrote:
> http://d.puremagic.com/issues/show_bug.cgi?id=2414
> 
>            Summary: enum is dynamically evaluated, yum
>            Product: D
>            Version: unspecified
>           Platform: PC
>         OS/Version: Linux
>             Status: NEW
>           Severity: normal
>           Priority: P2
>          Component: DMD
>         AssignedTo: bugzilla@digitalmars.com
>         ReportedBy: andrei@metalanguage.com
> 
> 
> Just compile this, run it, and have a laugh:
> 
> import std.stdio;
> 
> void main() {
>     double a = 1, b = 2;
>     enum c = a + b;
>     writeln(c);
>     a = 2, b = 3;
>     writeln(c);
> }
> 
> 

... :S



-- 
Bruno Medeiros - Software Developer, MSc. in CS/E graduate
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
June 19, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=2414


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |k.hara.pg@gmail.com


--- Comment #2 from Kenji Hara <k.hara.pg@gmail.com> 2011-06-19 04:02:22 PDT ---
On trunk dmd (d36b3b12fc4814e59f3a0d680b8700e787b1ceff),
----
test.d(6): Error: variable a cannot be read at compile time
test.d(6): Error: variable b cannot be read at compile time
----

It seems to me that this issue has been resolved.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 19, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=2414


kennytm@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |kennytm@gmail.com
         Resolution|                            |FIXED


--- Comment #3 from kennytm@gmail.com 2011-06-19 12:34:17 PDT ---
This has been fixed in commit fc67 "Ensure compile-time constants are not variables(!)". Thanks Don. There should be a test case though.

https://github.com/D-Programming-Language/dmd/commit/fc67046cf1e66182d959309fb15ef9e2d4c266b9

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------