Bug 1336 – Internal error when trying to construct a class declared within a unittest from a templated class.
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2007-07-11T18:17:00Z
Last change time
2014-02-16T15:23:02Z
Assigned to
bugzilla
Creator
aaroncraelius
Comments
Comment #0 by aaroncraelius — 2007-07-11T18:17:52Z
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);
}
Comment #1 by bugzilla — 2007-07-12T13:17:39Z
If you put 'static' in front of the class declaration, it'll work.
Comment #2 by aaroncraelius — 2007-07-12T13:31:07Z
(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 ;-)