Bug 3662 – Wrong compile error within struct constructor and C-style initializer
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
All
Creation time
2010-01-01T07:17:00Z
Last change time
2015-06-09T01:27:13Z
Keywords
diagnostic, patch
Assigned to
nobody
Creator
rayerd.wiz
Comments
Comment #0 by rayerd.wiz — 2010-01-01T07:17:36Z
// main.d
import std.stdio;
struct S
{
this(int x) {}
}
class A
{
const S s = {1};
}
void main() {}
$ dmd main.d
Error: struct S has constructors, cannot use { initializers }, use S( initializers ) instead
This error message is written to standard output, but standard error output, and has not an error line number.
Comment #1 by clugdbug — 2010-02-15T02:03:08Z
*** Issue 3802 has been marked as a duplicate of this issue. ***
Comment #2 by clugdbug — 2010-06-04T12:46:36Z
Trivial. Missing 'loc' in error call.
PATCH: init.c, StructInitializer::semantic(), line 158.
if (ad->ctor)
- error("%s %s has constructors, cannot use { initializers },
use
+ error(loc, "%s %s has constructors, cannot use { initializers }, use %s( initializers ) instead",
ad->kind(), ad->toChars(), ad->toChars());