Thread overview | |||||
---|---|---|---|---|---|
|
February 06, 2009 [Issue 2647] New: typedef's and struct constructors | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=2647 Summary: typedef's and struct constructors Product: D Version: 2.023 Platform: PC OS/Version: All Status: NEW Keywords: spec Severity: minor Priority: P2 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: s.d.hammett@googlemail.com 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. -- |
February 06, 2009 Re: [Issue 2647] New: typedef's and struct constructors | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | On Fri, 06 Feb 2009 11:25:37 +0300, <d-bugmail@puremagic.com> wrote:
> http://d.puremagic.com/issues/show_bug.cgi?id=2647
>
> Summary: typedef's and struct constructors
> Product: D
> Version: 2.023
> Platform: PC
> OS/Version: All
> Status: NEW
> Keywords: spec
> Severity: minor
> Priority: P2
> Component: DMD
> AssignedTo: bugzilla@digitalmars.com
> ReportedBy: s.d.hammett@googlemail.com
>
>
> 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.
>
>
Ouch!
|
November 19, 2009 [Issue 2647] typedef's and struct constructors | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2647 Don <clugdbug@yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |clugdbug@yahoo.com.au Resolution| |WONTFIX --- Comment #1 from Don <clugdbug@yahoo.com.au> 2009-11-19 07:56:32 PST --- Dropping typedef, so won't fix. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation