www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9775] New: Can no longer create a const Date in CTFE if the variable is explicitly typed

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9775

           Summary: Can no longer create a const Date in CTFE if the
                    variable is explicitly typed
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: jmdavisProg gmx.com



PDT ---
In 2.061, this compiled:

import std.datetime;
const Date date = Date(2012, 12, 21);
void main() {}

In 2.062 (and the current master), it gives

/usr/include/D/phobos/std/datetime.d(13542): Error: Internal Compiler Error:
CTFE literal cast(short)1
dmd: ctfeexpr.c:353: Expression* copyLiteral(Expression*): Assertion `0'
failed.
Aborted (core dumped)

It works if it's changed to

import std.datetime;
const date = Date(2012, 12, 21);
void main() {}

It also works if date is made non-const

Date date = Date(2012, 12, 21);

But it doesn't work even without const, if it's an enum

enum Date date = Date(2012, 12, 21);

though as with normal variables, if the type is not given explicitly to the
enum, it compiles just fine.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 21 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9775


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull



https://github.com/D-Programming-Language/dmd/pull/1824

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 01 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9775


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |oivind.loe gmail.com



*** Issue 9847 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 02 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9775




Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/79309eb016fa7271d0477a4adf77560fa3396d6c
fix Issue 9775 - Can no longer create a const Date in CTFE if the variable is
explicitly typed

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


[REG2.062] Issue 9775 - Can no longer create a const Date in CTFE if the
variable is explicitly typed

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 03 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9775


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED


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