1336 – Internal error when trying to construct a class declared within a unittest from a templated class.

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 1336 - Internal error when trying to construct a class declared within a unittest from a templated class.
Summary: Internal error when trying to construct a class declared within a unittest fr...
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 Windows
: P3 normal
Assignee: Walter Bright
URL:
Keywords:
Depends on:
Blocks:
Reported: 2007年07月11日 18:17 UTC by Aaron Craelius
Modified: 2014年02月16日 15:23 UTC (History)
0 users

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Aaron Craelius 2007年07月11日 18:17:52 UTC
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 Walter Bright 2007年07月12日 13:17:39 UTC
If you put 'static' in front of the class declaration, it'll work.
Comment 2 Aaron Craelius 2007年07月12日 13:31:07 UTC
(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 ;-)
Comment 3 Walter Bright 2007年07月12日 14:06:40 UTC
I agree, which is why the bug isn't closed yet.
Comment 4 Walter Bright 2007年07月30日 15:53:16 UTC
Fixed DMD 1.019 and 2.003


AltStyle によって変換されたページ (->オリジナル) /