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
Comment #3 by github-bugzilla — 2018-04-17T11:34:32Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/4a023ae3f23480110ab5ac3e0a4915e1b0ad4b6d Fix Issue 7443 - Better diagnostic on wrongly written static constructor https://github.com/dlang/dmd/commit/af1d5bd9e10938c605938e2424de78dc941a24b3 Merge pull request #8164 from RazvanN7/Issue_7443 Fix Issue 7443 - Better diagnostic on wrongly written static constructor merged-on-behalf-of: Razvan Nitu <[email protected]>
Comment #4 by dlang-bot — 2019-07-09T07:40:25Z
dlang/dmd pull request #10152 "Fix Issue 7443 - Better diagnostic on wrongly written static constructor: Deprecation --> Error" was merged into master: - 1762464837d03426b6b4d8c7c5fecdb7684a5eb2 by JinShil: Fix Issue 7443 - Better diagnostic on wrongly written static constructor: Deprecation --> Error https://github.com/dlang/dmd/pull/10152