Thread overview | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
March 17, 2004 bug compiler message | ||||
---|---|---|---|---|
| ||||
compiler said: declaration __anonymous.k is already defined from: foreach(char[] key, TreeIter ; iterMap) { printf("key = %.*s\n", key); } // missing var after TreeIter Ant |
March 17, 2004 Re: bug compiler message | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ant | Ant wrote: > compiler said: > > declaration __anonymous.k is already defined > > from: > > foreach(char[] key, TreeIter ; iterMap) > { > printf("key = %.*s\n", key); > } > > // missing var after TreeIter > > Ant I don't quite know how you got your error message, but this is the message I came up with (Windows version): Assertion failure: '0' on line 658 in file 'statement.c' abnormal program termination It's not very descriptive, either. Here's the code I used (so that everyone can play along at home): void main() { char[] iterMap; foreach(char[] key, int; iterMap) /* missing identifier before ; */ { printf("key = %.*s\n", key); } } -- Justin http://jcc_7.tripod.com/d/ |
March 17, 2004 Re: bug compiler message | ||||
---|---|---|---|---|
| ||||
Posted in reply to J C Calvarese | J C Calvarese wrote: > Ant wrote: > >> compiler said: >> >> declaration __anonymous.k is already defined >> >> from: >> >> foreach(char[] key, TreeIter ; iterMap) >> { >> printf("key = %.*s\n", key); >> } >> >> // missing var after TreeIter >> >> Ant > > > I don't quite know how you got your error message, but this is the message I came up with (Windows version): > > Assertion failure: '0' on line 658 in file 'statement.c' > > abnormal program termination > > > It's not very descriptive, either. > > Here's the code I used (so that everyone can play along at home): > > > void main() > { > char[] iterMap; > > foreach(char[] key, int; iterMap) /* missing identifier before ; */ > { > printf("key = %.*s\n", key); > } > > } > > Shouldn't that be? void main() { char[] iterMap; foreach(int i, char key; iterMap) { printf("key = %.*s\n", key); } } or even simpler? void main() { char[] iterMap; foreach(char key; iterMap) { printf("key = %.*s\n", key); } } -- -Anderson: http://badmama.com.au/~anderson/ |
March 17, 2004 Re: bug compiler message | ||||
---|---|---|---|---|
| ||||
Posted in reply to J Anderson | J Anderson wrote: > J C Calvarese wrote: > >> Ant wrote: >> >>> compiler said: >>> >>> declaration __anonymous.k is already defined >>> >>> from: >>> >>> foreach(char[] key, TreeIter ; iterMap) >>> { >>> printf("key = %.*s\n", key); >>> } >>> >>> // missing var after TreeIter >>> >>> Ant >> >> >> >> I don't quite know how you got your error message, but this is the message I came up with (Windows version): >> >> Assertion failure: '0' on line 658 in file 'statement.c' >> >> abnormal program termination >> >> >> It's not very descriptive, either. >> >> Here's the code I used (so that everyone can play along at home): >> >> >> void main() >> { >> char[] iterMap; >> >> foreach(char[] key, int; iterMap) /* missing identifier before ; */ >> { >> printf("key = %.*s\n", key); >> } >> >> } >> >> > Shouldn't that be? > > void main() > { > char[] iterMap; > > foreach(int i, char key; iterMap) > { > printf("key = %.*s\n", key); > } > } > > or even simpler? > > void main() > { > char[] iterMap; > > foreach(char key; iterMap) > { > printf("key = %.*s\n", key); > } > } > Actually, there's a semantic bug here: Do you want to go cycle though chars or strings? I mean you should either use: printf("key = %c\n", key); or (with the appropriate changes in the for loop) char[][] iterMap; -- -Anderson: http://badmama.com.au/~anderson/ |
March 17, 2004 Re: bug compiler message | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ant | Ant wrote: >compiler said: > >declaration __anonymous.k is already defined > >from: > >foreach(char[] key, TreeIter ; iterMap) >{ > printf("key = %.*s\n", key); >} > >// missing var after TreeIter > >Ant > You mean something like the following? void main() { char[][] iterMap; iterMap.length = 10; iterMap[0] = "hi"; foreach(char [] key; iterMap) { printf("key = %.*s\n", key); } } -- -Anderson: http://badmama.com.au/~anderson/ |
March 17, 2004 Re: bug compiler message | ||||
---|---|---|---|---|
| ||||
Posted in reply to J Anderson | J Anderson wrote: > J Anderson wrote: [...] >> J C Calvarese wrote: [...] >>> Ant wrote: >>> [...] >>> >> Shouldn't that be? >> >> void main() >> { >> char[] iterMap; >> >> foreach(int i, char key; iterMap) >> { >> printf("key = %.*s\n", key); >> } >> } >> >> > Actually, there's a semantic bug here: > Do you want to go cycle though chars or strings? > > I mean you should either use: > printf("key = %c\n", key); > or (with the appropriate changes in the for loop) > char[][] iterMap; I realize that my code was invalid. I think Ant's point was that nonsense was emitted by DMD instead of a helpful error message. (Hence the subject "bug compiler MESSAGE".) I'm not sure what Ant was trying to do. I suspect he figured out how to accomplish his goal, but he was trying to clue Walter into a circumstance where the compiler produces an odd message. I spent a little time completing his example to try to reproduce his problem. I though my code had an interesting result, too, so I shared it. Sorry, if I was unclear in my first reply. -- Justin http://jcc_7.tripod.com/d/ |
March 17, 2004 Re: bug compiler message | ||||
---|---|---|---|---|
| ||||
Posted in reply to J C Calvarese | In article <c38de7$2rmi$1@digitaldaemon.com>, J C Calvarese says... > >Ant wrote: >> compiler said: >> >> declaration __anonymous.k is already defined >> >> from: >> >> foreach(char[] key, TreeIter ; iterMap) >> { >> printf("key = %.*s\n", key); >> } >> >> // missing var after TreeIter >> >> Ant > >I don't quite know how you got your error message, but this is the message I came up with (Windows version): > > Assertion failure: '0' on line 658 in file 'statement.c' > > abnormal program termination > I sorry two mistakes on my post 1. it's an associative array, 2. I changed the code before posting but forgot to copy the compiler message again: foreach(char[] k, TreeIter ; iterMap) { printf("k = %.*s\n", k); } // it has "k" instead of "key" Ant |
March 17, 2004 Re: bug compiler message | ||||
---|---|---|---|---|
| ||||
Posted in reply to J Anderson | In article <c38eeh$2t4s$1@digitaldaemon.com>, J Anderson says... > >Ant wrote: > >>compiler said: >> >>declaration __anonymous.k is already defined >> >>from: >> >>foreach(char[] key, TreeIter ; iterMap) >>{ >> printf("key = %.*s\n", key); >>} >> >>// missing var after TreeIter >> >>Ant >> > >You mean something like the following? TreeIter[char[]] iterMap; It's a DUI program (leds). Ant |
March 17, 2004 Re: bug compiler message | ||||
---|---|---|---|---|
| ||||
Posted in reply to J C Calvarese | In article <c38h8i$31km$1@digitaldaemon.com>, J C Calvarese says... > >I realize that my code was invalid. I think Ant's point was that nonsense was emitted by DMD instead of a helpful error message. (Hence the subject "bug compiler MESSAGE".) that's it! Do he have a better subject? (I'm sure I'll find more...) > >I'm not sure what Ant was trying to do. I suspect he figured out how to accomplish his goal, Yes, thank you, I don't require assistance with this problem, sorry if I mislead you... Ant |
March 17, 2004 Re: bug compiler message | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ant | Ant wrote: > In article <c38de7$2rmi$1@digitaldaemon.com>, J C Calvarese says... > >>Ant wrote: >> >>>compiler said: >>> >>>declaration __anonymous.k is already defined [...] > > I sorry two mistakes on my post > 1. it's an associative array, > 2. I changed the code before posting but forgot to copy the compiler > message again: > > foreach(char[] k, TreeIter ; iterMap) > { > printf("k = %.*s\n", k); > } > // it has "k" instead of "key" > > Ant Now, I've seen it for myself (WinXP). Wow, that may be the strangest error message I've ever seen. Here's the code I used: alias int TreeIter; void main() { char[char[]] iterMap; foreach(char[] k, TreeIter ; iterMap) { printf("k = %.*s\n", k); } } -- Justin http://jcc_7.tripod.com/d/ |
Copyright © 1999-2021 by the D Language Foundation