www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9040] New: Assertion `precedence[e->op] != PREC_zero' failed instantiating anonymous class at compile time

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

           Summary: Assertion `precedence[e->op] != PREC_zero' failed
                    instantiating anonymous class at compile time
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: ogondza gmail.com



An assertion seems to fail when instantiating anonymous class at compile time.

Instantiating non-anonymous class gives meaningful error message.

class BaseClass {}

void main() {

    // OK
    BaseClass instance = new class BaseClass {};

    // Error: cannot evaluate new BaseClass at compile time
    static BaseClass staticInstance = new BaseClass();

    //dmd: expression.c:1276: void expToCBuffer(OutBuffer*, HdrGenState*,
Expression*, PREC): Assertion `precedence[e->op] != PREC_zero' failed.
    //Aborted
    static BaseClass staticAnonInstance = new class BaseClass {};
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 17 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9040


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc



On the latest dmd 2.061head this program:


class BaseClass {}
void main() {
    BaseClass instance = new class BaseClass {};
    static BaseClass staticAnonInstance = new class BaseClass {};
}


Gives me (32 bit, Windows):

test.d(4): Error: non-constant expression cast(BaseClass)¨6U

The error message doesn't look good.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 17 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9040


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |andrej.mitrovich gmail.com
         Resolution|                            |WORKSFORME



06:03:54 PDT ---
In 2.063.2 this now prints:

test.d(9): Error: variable test.main.staticInstance is mutable. Only const or
immutable class thread local variable are allowed, not test.BaseClass

Unfortunately there's a new issue:

-----
class BaseClass {}

void main()
{
    static BaseClass staticAnonInstance = new class BaseClass {};
}
-----

However this is a separate issue, so I'll file it as a new bug.

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


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|WORKSFORME                  |



06:08:18 PDT ---
Argh, I just saw it's labeled as Posix and x64. Is there still a linker failure
for you on that platform? I've reopened the issue, if it's fixed please mark it
as WORKSFORME. Thanks.

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




06:08:54 PDT ---

 Unfortunately there's a new issue:
 
 -----
 class BaseClass {}
 
 void main()
 {
     static BaseClass staticAnonInstance = new class BaseClass {};
 }
 -----
 
 However this is a separate issue, so I'll file it as a new bug.
W.r.t. this it's a linker failure, and I've filed Issue 11126 for it. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 26 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9040




06:09:40 PDT ---

 Argh, I just saw it's labeled as Posix and x64. Is there still a linker failure
 for you on that platform? I've reopened the issue, if it's fixed please mark it
 as WORKSFORME. Thanks.
I meant to ask if the compiler is still crashing, the linker issue is separate (Issue 11126). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 26 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9040





I do not longer observe the compiler failure. In v2.063.2, I am hitting Issue
11126 instead when running:
-----
class BaseClass {}

void main()
{
    static BaseClass staticAnonInstance = new class BaseClass {};
}
-----

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