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


--- Comment #0 from ogondza <ogondza gmail.com> 2012-11-17 08:03:45 PST ---
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


--- Comment #1 from bearophile_hugs eml.cc 2012-11-17 08:32:33 PST ---
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


--- Comment #2 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-09-26
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                  |


--- Comment #3 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-09-26
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



--- Comment #4 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-09-26
06:08:54 PDT ---
(In reply to comment #2)
 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



--- Comment #5 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-09-26
06:09:40 PDT ---
(In reply to comment #3)
 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



--- Comment #6 from ogondza <ogondza gmail.com> 2013-09-28 03:31:11 PDT ---
(In reply to comment #5)
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