www.digitalmars.com         C & C++   DMDScript  

D - bug compiler message

reply Ant <duitoolkit yahoo.ca> writes:
compiler said:

declaration __anonymous.k is already defined

from:

foreach(char[] key, TreeIter ; iterMap)
{
	printf("key = %.*s\n", key);
}

// missing var after TreeIter

Ant
Mar 16 2004
next sibling parent reply J C Calvarese <jcc7 cox.net> writes:
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/
Mar 16 2004
next sibling parent reply J Anderson <REMOVEanderson badmama.com.au> writes:
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/
Mar 16 2004
parent reply J Anderson <REMOVEanderson badmama.com.au> writes:
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/
Mar 16 2004
parent reply J C Calvarese <jcc7 cox.net> writes:
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/
Mar 16 2004
parent Ant <Ant_member pathlink.com> writes:
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
Mar 16 2004
prev sibling parent reply Ant <Ant_member pathlink.com> writes:
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
Mar 16 2004
parent reply J C Calvarese <jcc7 cox.net> writes:
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/
Mar 16 2004
parent larry cowan <larry_member pathlink.com> writes:
In article <c38ink$2ds$1 digitaldaemon.com>, J C Calvarese says...
Ant wrote:
 In article <c38de7$2rmi$1 digitaldaemon.com>, J C Calvarese says...
 
Ant wrote:

compiler said:

declaration __anonymous.k is already defined
dmd/src/dmd/dsymbol.c line 76 dmd/src/dmd/template.c line 1302
[...]
 
 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/
Mar 17 2004
prev sibling parent reply J Anderson <REMOVEanderson badmama.com.au> writes:
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/
Mar 16 2004
parent Ant <Ant_member pathlink.com> writes:
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
Mar 16 2004