dmd/compiler/test/fail_compilation/fail336.d
Nick Treleaven 13b0745e33
Fix error when struct initializer isn't accepted (#21086)
* Fix error when struct initializer isn't accepted

* Rename StructDeclaration.hasRegularCtor parameter to ignoreDisabled

checkDisabled detected disabled ctors when it was false, which was
confusing!

* Update tests
2025-03-26 11:28:07 +01:00

17 lines
427 B
D

/*
TEST_OUTPUT:
---
fail_compilation/fail336.d(17): Error: Cannot use struct initializer syntax for struct `S` because it has a constructor
fail_compilation/fail336.d(17): Use `S( arguments )` instead of `{ initializers }`
---
*/
// https://issues.dlang.org/show_bug.cgi?id=3476
// C-style initializer for structs must be disallowed for structs with a constructor
struct S
{
int a;
this(int) {}
}
S s = { 1 };