D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 2647 - typedef's and struct constructors
Summary: typedef's and struct constructors
Status: RESOLVED WONTFIX
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 All
: P2 minor
Assignee: No Owner
URL:
Keywords: spec
Depends on:
Blocks:
 
Reported: 2009-02-06 02:25 UTC by simon
Modified: 2015-06-09 01:21 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description simon 2009-02-06 02:25:38 UTC
when using typedefs of structs
their constructors return the original type instead of the new type

struct Ca {
	this(int a) {
		_answer = a / 2;
	}

	int _answer;
}

void testClasses() {
	typedef Ca Da;

	Ca a = Ca(84);
	Da c = Da(84);
	
}

tests0.d(38):

Error: cannot implicitly convert expression (((Ca __ctmp276 = __ctmp276 = 0;
) , __ctmp276).this(84)) of type Ca to Da

A cast is required for the code to work.
Comment 1 Don 2009-11-19 07:56:32 UTC
Dropping typedef, so won't fix.