D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3662 - Wrong compile error within struct constructor and C-style initializer
Summary: Wrong compile error within struct constructor and C-style initializer
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other All
: P2 normal
Assignee: No Owner
URL:
Keywords: diagnostic, patch
: 3802 (view as issue list)
Depends on:
Blocks:
 
Reported: 2010-01-01 07:17 UTC by Haruki Shigemori
Modified: 2015-06-09 01:27 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Haruki Shigemori 2010-01-01 07:17:36 UTC
// 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 Don 2010-02-15 02:03:08 UTC
*** Issue 3802 has been marked as a duplicate of this issue. ***
Comment 2 Don 2010-06-04 12:46:36 UTC
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());
Comment 3 Walter Bright 2010-06-09 17:30:09 UTC
http://www.dsource.org/projects/dmd/changeset/531