www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1336] New: Internal error when trying to construct a class declared within a unittest from a templated class.

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

           Summary: Internal error when trying to construct a class declared
                    within a unittest from a templated class.
           Product: D
           Version: 1.018
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P3
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: aaroncraelius gmail.com


A templated class instantiated with a class declared in a unittest block cannot
call the constructor for that class, but instead of writing an error the
compiler returns:
Internal error: toir.c 182

The following code will cause this error to appear:
class X(T)
{
        void test()
        {
                auto t = new T;
        }
}

unittest
{
        class DummyClass
        {
        }

        auto x = new X!(DummyClass);
}

The code compiles fine if it is changed to this:
class X(T)
{
        void test()
        {
                auto t = new T;
        }
}

class DummyClass
{
}

unittest
{
        auto x = new X!(DummyClass);
}


-- 
Jul 11 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1336






If you put 'static' in front of the class declaration, it'll work.


-- 
Jul 12 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1336







 If you put 'static' in front of the class declaration, it'll work.
 
Thanks, Walter. It still would be nice to get an error message for that though ;-) --
Jul 12 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1336






I agree, which is why the bug isn't closed yet.


-- 
Jul 12 2007
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1336


bugzilla digitalmars.com changed:

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





Fixed DMD 1.019 and 2.003


-- 
Jul 30 2007