www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5865] New: __dollar cannot be read at compile time

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

           Summary: __dollar cannot be read at compile time
           Product: D
           Version: D2
          Platform: All
        OS/Version: Windows
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: changlon gmail.com



this working on dmd 2.052 release,  throw error on dmd git master .
------------------------------------------
class Test1(string name, string file = __FILE__){
    static const _file    = file ;
    void test1(){
        static const string file2 = _file[0..$]  ;
    }
}

void main(){
    auto obj    = new Test1!"Test1" ;
    obj.test1();
}
-----------------------------------------
test.d(5): Error: variable __dollar cannot be read at compile time
test.d(5): Error: variable __dollar cannot be read at compile time
test.d(10): Error: template instance test.Test1!("Test1") error instantiating

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


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch, rejects-valid
                 CC|                            |clugdbug yahoo.com.au



PATCH dsymbol.c, line 1181.

        if (!*pvar)             // if not already initialized
        {   /* Create variable v and set it to the value of $,
             * which will be a constant.
             */
            VarDeclaration *v = new VarDeclaration(loc, Type::tsize_t,
Id::dollar, NULL);

            if (ce->op == TOKvar)
            {   // if ce is const, get its initializer
-                ce = fromConstInitializer(WANTvalue, ce);
+                ce = fromConstInitializer(WANTvalue | WANTexpand, ce);
            }

            if (ce->op == TOKstring)
            {   /* It is for a string literal, so the
                 * length will be a const.
                 */

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


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla digitalmars.com



10:43:21 PDT ---
D2 fix:
https://github.com/D-Programming-Language/dmd/commit/0c9c52c7123e7336ce732e72099dbebd183742e2

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


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED



11:30:48 PDT ---
D1 fix:
https://github.com/D-Programming-Language/dmd/commit/bd196a9020883d94c7b7c4d8a91943d5735f4f3c

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