mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 21:21:48 +03:00

* Add named argument parsing * Refactor StructInitializer semantic to make it reusable * Move out `resolveStructLiteralNamedArgs` * Resolve named args in struct literal * Add tests * Check for errors returned by `resolveStructLiteralNamedArgs` * Expand names along with tuples * Update error messages in tests * Convert tabs to spaces in named arg test * Fix style of `resolveStructLiteralNamedArgs` * Clarify 'fixme' comment in expandTuples * Add example to `expandTuples` documentation * Update compiler/src/dmd/initsem.d Co-authored-by: Razvan Nitu <razvan.nitu1305@gmail.com> * Add overlapping initialization supplemental error to Struct Initializer * Improve "too many initializers" error message Co-authored-by: Razvan Nitu <razvan.nitu1305@gmail.com>
24 lines
268 B
D
24 lines
268 B
D
|
|
struct S
|
|
{
|
|
string name;
|
|
int x;
|
|
int y;
|
|
}
|
|
|
|
|
|
immutable S s = S(x: 2, 3, name: "boo");
|
|
|
|
static assert(s.x == 2);
|
|
static assert(s.y == 3);
|
|
static assert(s.name == "boo");
|
|
|
|
union U
|
|
{
|
|
float f;
|
|
int i;
|
|
}
|
|
|
|
immutable U u = U(i: 2);
|
|
|
|
static assert(u.i == 2);
|