July 27, 2014 [Issue 13209] Refused union initialization | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=13209 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |INVALID --- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> --- Introduced in: https://github.com/D-Programming-Language/dmd/pull/3400 However I think this is not a regression, because > struct Foo { > union { > immutable static struct { double x, y; } This line is an anonymous struct declaration with 'static' attribute, so x and y should become immutable static field. Therefore > immutable double[2] v; > } > Foo bar() { > return Foo(y, x); > } > } > void main() {} > > > dmd 2.066beta4 gives: > > test.d(7,19): Error: more initializers than fields (1) of Foo In git head, Foo.x and Foo.y are correctly analyzed as static fields, and Foo has only one instance field v. -- |
July 27, 2014 [Issue 13209] Refused union initialization | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=13209 Dicebot <public@dicebot.lv> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |public@dicebot.lv --- Comment #2 from Dicebot <public@dicebot.lv> --- > This line is an anonymous struct declaration with 'static' attribute, so x and y should become immutable static field. Is this documented anywhere? Can't see it at http://dlang.org/struct.html and this is different from named struct behavior. -- |
Copyright © 1999-2021 by the D Language Foundation