Bug 7443 – Better diagnostic on wrongly written static constructor
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-02-05T06:33:57Z
Last change time
2019-07-09T07:40:25Z
Keywords
accepts-invalid, diagnostic, link-failure
Assigned to
No Owner
Creator
bearophile_hugs
Comments
Comment #0 by bearophile_hugs — 2012-02-05T06:33:57Z
This is a spin-off of bug 5868
An example of code that gives an error, for already defined constructor:
class Foo {
public static {
this() {}
}
public {
this() {}
}
}
void main() {}
The spec say:
"The static in the static constructor declaration is not an attribute, it must
appear immediately before the this"
So in this diagnostic enhancement request I ask for the compiler to find such mistakes, and report them nicely to the programmer.
Comment #1 by dlang-bugzilla — 2017-07-02T13:44:06Z
To clarify, the example given currently (wrongly) compiles but fails to link due to a "multiple definition" error.
Upgrading from enhancement since it seems like an accepts-invalid.
Comment #2 by razvan.nitu1305 — 2018-04-11T15:02:18Z