Bug 14163 – No line number for error with disabled class constructor

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-02-10T09:21:00Z
Last change time
2015-02-21T09:11:17Z
Keywords
diagnostic, pull
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2015-02-10T09:21:17Z
class Foo { @disable this(); } class Bar : Foo { @disable this(); this(int i) {} } void main() {} Gives no line number in the error message: Error: constructor test.Foo.this is not callable because it is annotated with @disable Additionally this gives a linker error, but perhaps the front-end should catch this at compile-time: class Foo { @disable this(); this(int i) {} } void main() {} test.obj(test) Error 42: Symbol Undefined _D4test3Foo6__ctorMFZC4test3Foo
Comment #1 by bearophile_hugs — 2015-02-10T09:39:07Z
Some comments by Steven Schveighoffer and Jonathan M Davis: >> It really is only useful in the case where you don't want to define a >> constructor. Which probably means -- you don't want to use a class anyway ;) >> >> But for completeness, it seems like I should be able to have the option >> of disabling something the compiler does by default. Even if it's next >> to useless. > > I suppose that it makes sense if you want to make it so that the class can't > be constructed (and actually, now that I look at it, that's what > std.datetime.Clock does), but if another constructor has been declared, then > it should be probably be disallowed at compile time - especially if it's > resulting in a linker error.
Comment #2 by k.hara.pg — 2015-02-10T13:00:58Z
Comment #3 by k.hara.pg — 2015-02-10T13:03:38Z
(In reply to bearophile_hugs from comment #0) > class Foo { > @disable this(); > } > class Bar : Foo { > @disable this(); > this(int i) {} > } > void main() {} > > > > Gives no line number in the error message: > > Error: constructor test.Foo.this is not callable because it is annotated > with @disable > > > Additionally this gives a linker error, but perhaps the front-end should > catch this at compile-time: > > > class Foo { > @disable this(); > this(int i) {} > } > void main() {} > > > test.obj(test) > Error 42: Symbol Undefined _D4test3Foo6__ctorMFZC4test3Foo I separated the link-failure issue to: https://issues.dlang.org/show_bug.cgi?id=14165
Comment #4 by github-bugzilla — 2015-02-10T15:15:47Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/5a38707ce0a403273a6bbf894e01669372dadd49 fix Issue 14163 - No line number for error with disabled class constructor https://github.com/D-Programming-Language/dmd/commit/d957c6455f0a78757e704b6d1308781c29f7f33b Merge pull request #4399 from 9rnsr/fix14163 Issue 14163 - No line number for error with disabled class constructor
Comment #5 by github-bugzilla — 2015-02-21T09:11:17Z