Thread overview
[Issue 1336] New: Internal error when trying to construct a class declared within a unittest from a templated class.
Jul 11, 2007
d-bugmail
Jul 12, 2007
d-bugmail
Jul 12, 2007
d-bugmail
Jul 12, 2007
d-bugmail
Jul 30, 2007
d-bugmail
July 11, 2007
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);
}


-- 

July 12, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1336





------- Comment #1 from bugzilla@digitalmars.com  2007-07-12 13:17 -------
If you put 'static' in front of the class declaration, it'll work.


-- 

July 12, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1336





------- Comment #2 from aaroncraelius@gmail.com  2007-07-12 13:31 -------
(In reply to comment #1)
> 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 ;-)


-- 

July 12, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1336





------- Comment #3 from bugzilla@digitalmars.com  2007-07-12 14:06 -------
I agree, which is why the bug isn't closed yet.


-- 

July 30, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1336


bugzilla@digitalmars.com changed:

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




------- Comment #4 from bugzilla@digitalmars.com  2007-07-30 15:53 -------
Fixed DMD 1.019 and 2.003


--