Bug 8928 – Poor error message for derived class without constructor

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-11-01T05:09:00Z
Last change time
2015-06-09T05:11:48Z
Keywords
diagnostic, pull
Assigned to
andrej.mitrovich
Creator
clugdbug

Comments

Comment #0 by clugdbug — 2012-11-01T05:09:18Z
class X { this(int n) {} } class Y : X { } qef.d(5): Error: constructor qef.Y.this no match for implicit super() call in constructor ---- But Y doesn't have a constructor! Seems the compiler generates an implicit constructor, and then complains that it's erroneous. Actually I'm not sure why it doesn't generate this(int n) { super(n); }, but that's a different issue.
Comment #1 by andrej.mitrovich — 2012-11-01T22:26:45Z
How about: Error: synthesized constructor qef.Y.this no match for implicit super() call in constructor
Comment #2 by issues.dlang — 2012-11-01T22:42:08Z
"Synthesized?" That's a very odd choice of words, and actually, I'd argue that it's outright incorrect. How about something more like Error: Cannot generate default constructor for qef.Y, because its base class, qef.X, has no default constructor.
Comment #3 by andrej.mitrovich — 2012-11-01T22:48:02Z
(In reply to comment #2) > "Synthesized?" That's a very odd choice of words, and actually, I'd argue that > it's outright incorrect. It's standard terminology, you can look up the C++ reference manual if you wish. Here's a sample g++ error when the compiler implicitly generates a method: /usr/include/c++/4.4/iosfwd:56: note: synthesized method ‘std::basic_ios >& std::basic_ios >::operator=(const std::basic_ios >&)’ first required here
Comment #4 by andrej.mitrovich — 2012-11-01T22:48:53Z
(In reply to comment #3) > (In reply to comment #2) > > "Synthesized?" That's a very odd choice of words, and actually, I'd argue that > > it's outright incorrect. > > It's standard terminology But I'm not saying it's the best choice of words. So suggestions are welcome.
Comment #5 by issues.dlang — 2012-11-01T23:13:41Z
Well, it really doesn't match the definition of synthesized at all, so I have to wonder about whoever picked it for C++. Regardless, using it in an error message like that isn't going to be clear to most programmers.
Comment #6 by andrej.mitrovich — 2012-11-29T14:42:53Z
Comment #7 by github-bugzilla — 2012-12-09T09:59:51Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/6a4840212b1ee0611c9c8fecc59ec8500e8999ea Fixes Issue 8928 - Improve error message with implicitly generated constructor. https://github.com/D-Programming-Language/dmd/commit/4cc63a038e27356d5d60a93e57b794b37167cab0 Merge pull request #1336 from AndrejMitrovic/Fix8928 [diag] Issue 8928 - Improve error message with implicitly generated constructor