digitalmars.D.learn - Problem about using struct
- Tongzhou Li (17/17) Jun 24 2012 Hello! I'm learning D, and wrote some sample codes with D.
- Kenji Hara (5/22) Jun 25 2012 Unfortunately, this is a dmd bug that yet not fixed.
- Tongzhou Li (2/27) Jun 25 2012 Well, that's too bad...
- bearophile (8/12) Jun 25 2012 At first sight your code seems OK.
Hello! I'm learning D, and wrote some sample codes with D. I wrote: http://ideone.com/VY7ES It failed to compile; I got 2 errors: main.d(19): Error: constructor main.carry!(int,int,int,int,int).carry.this (int delegate(int, int _param_0, int _param_1, int _param_2) _f) is not callable using argument types (int) main.d(19): Error: cannot implicitly convert expression (1) of type int to int delegate(int, int _param_0, int _param_1, int _param_2) Compiler used: DMD v2.059 (I used lambda expression which ideone doesn't support) Don't know what it means, I don't call any constructor in Line 19. Then I tried to use "class" instead of "struct" (http://ideone.com/ZI2Tn), it worked fine. So what's wrong with that? Sorry for my poor English:)
Jun 24 2012
On Monday, 25 June 2012 at 06:05:34 UTC, Tongzhou Li wrote:Hello! I'm learning D, and wrote some sample codes with D. I wrote: http://ideone.com/VY7ES It failed to compile; I got 2 errors: main.d(19): Error: constructor main.carry!(int,int,int,int,int).carry.this (int delegate(int, int _param_0, int _param_1, int _param_2) _f) is not callable using argument types (int) main.d(19): Error: cannot implicitly convert expression (1) of type int to int delegate(int, int _param_0, int _param_1, int _param_2) Compiler used: DMD v2.059 (I used lambda expression which ideone doesn't support) Don't know what it means, I don't call any constructor in Line 19. Then I tried to use "class" instead of "struct" (http://ideone.com/ZI2Tn), it worked fine. So what's wrong with that? Sorry for my poor English:)Unfortunately, this is a dmd bug that yet not fixed. http://d.puremagic.com/issues/show_bug.cgi?id=6036 As far as I know, there is no workaround... Kenji Hara
Jun 25 2012
On Monday, 25 June 2012 at 10:10:56 UTC, Kenji Hara wrote:On Monday, 25 June 2012 at 06:05:34 UTC, Tongzhou Li wrote:Well, that's too bad...Hello! I'm learning D, and wrote some sample codes with D. I wrote: http://ideone.com/VY7ES It failed to compile; I got 2 errors: main.d(19): Error: constructor main.carry!(int,int,int,int,int).carry.this (int delegate(int, int _param_0, int _param_1, int _param_2) _f) is not callable using argument types (int) main.d(19): Error: cannot implicitly convert expression (1) of type int to int delegate(int, int _param_0, int _param_1, int _param_2) Compiler used: DMD v2.059 (I used lambda expression which ideone doesn't support) Don't know what it means, I don't call any constructor in Line 19. Then I tried to use "class" instead of "struct" (http://ideone.com/ZI2Tn), it worked fine. So what's wrong with that? Sorry for my poor English:)Unfortunately, this is a dmd bug that yet not fixed. http://d.puremagic.com/issues/show_bug.cgi?id=6036 As far as I know, there is no workaround... Kenji Hara
Jun 25 2012
Tongzhou Li:Don't know what it means, I don't call any constructor in Line 19. Then I tried to use "class" instead of "struct" (http://ideone.com/ZI2Tn), it worked fine. So what's wrong with that?At first sight your code seems OK. There is a well known compiler bug that makes it call the struct constructor instead of its opCall. I think there is already a pull request that fixes it in Bugzilla since some time (there are more than one hundred of those open). Bye, bearophile
Jun 25 2012