www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5890] New: ICE and wrong scope problem for 2nd argument in static assert with DMD on git master

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

           Summary: ICE and wrong scope problem for 2nd argument in static
                    assert with DMD on git master
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Mac OS X
            Status: NEW
          Keywords: ice-on-valid-code, rejects-valid
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: kennytm gmail.com



This is a problem on the git master. This does not affect 2.052.

The program below causes an ICE on the git master version:

-------------------------------------------------
class K {
    void f() {
        static assert(0, typeof(this).stringof);
    }
}

void main() {
    (new K).f;
}
-------------------------------------------------

x.d(6): Error: static assert  "K"c

Assertion failed: (this != enclosing), function Scope, file scope.c, line 132.
Abort trap
-------------------------------------------------

And the program below thinks the template parameter U does not exist:

-------------------------------------------------
class K {
    static void f(U)() {
        static assert(0, U.stringof);
    }
}

void main() {
    K.f!int();
}
-------------------------------------------------

x.d(6): Error: static assert  "int"c
x.d(11):        instantiated from here: f!(int)

x.d(6): Error: undefined identifier U
x.d(6): Error: static assert  __error
x.d(11):        instantiated from here: f!(int)
-------------------------------------------------

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


kennytm gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |http://d.puremagic.com/issu
                   |                            |es/show_bug.cgi?id=4097



Both problems were introduced in commit
7588ca35c5e723a8fccfbfc1db684114aa1e29aa when fixing issue 4097.

(https://github.com/D-Programming-Language/dmd/commit/7588ca35c5e723a8fccfbfc1db684114aa1e29aa)

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


kennytm gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch



The fix should be trivial:

diff --git a/src/staticassert.c b/src/staticassert.c
index 67a1e48..82aad9c 100644
--- a/src/staticassert.c
+++ b/src/staticassert.c
   -57,7 +57,7    void StaticAssert::semantic2(Scope *sc)
     sc = sc->push(sd);
     sc->flags |= SCOPEstaticassert;
     Expression *e = exp->semantic(sc);
-    sc->pop();
+    sc = sc->pop();
     if (e->op == TOKerror)
         return;
     e = e->optimize(WANTvalue | WANTinterpret);

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


Walter Bright <bugzilla digitalmars.com> changed:

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



00:03:12 PDT ---
https://github.com/D-Programming-Language/dmd/commit/3fcc2344681ab9d31d1897188f36051c9beb247f

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