February 15, 2006 duplicate union initialization | ||||
---|---|---|---|---|
| ||||
Attachments: | # class C{ # void dummy(){ # } # # union{ # int[] x = [1, 3]; # struct{ # int a; # int b; # } # } # } # # import std.stdio; # int main(){ # C c = new C(); # writefln("[%s, %s] = %s, %s", c.x[0], c.x[1], c.a, c.b); # return 0; # } The code above behaves as expected, but if the position of x and the anonymous struct are exchanged: # class C{ // line 1 # void dummy(){ # } # # union{ # struct{ # int a; // line 7 # int b; # } # int[] x = [1, 3]; // line 10 # } # } a.d(1): class a.C 2duplicate union initialization for x * I'd expect line 10 and 7 to be mentionted in the error message, not line 1. * The "2" in "2duplicate" seems to be a remainder of some debug logging. * Is it a bug, or an omission from the docs? Maybe the test case below is more suitable for discussion: # class C{ # union{ # struct{ # int a = 1; # int b; # } # struct{ # int c; # int d = 2; # } # } # } Thomas |
Copyright © 1999-2021 by the D Language Foundation