D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 14163 - No line number for error with disabled class constructor
Summary: No line number for error with disabled class constructor
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 minor
Assignee: No Owner
URL:
Keywords: diagnostic, pull
Depends on:
Blocks:
 
Reported: 2015-02-10 09:21 UTC by bearophile_hugs
Modified: 2015-02-21 09:11 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2015-02-10 09:21:17 UTC
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 bearophile_hugs 2015-02-10 09:39:07 UTC
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 Kenji Hara 2015-02-10 13:00:58 UTC
Fix diagnostic issue:
https://github.com/D-Programming-Language/dmd/pull/4399
Comment 3 Kenji Hara 2015-02-10 13:03:38 UTC
(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 github-bugzilla 2015-02-10 15:15:47 UTC
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 github-bugzilla 2015-02-21 09:11:17 UTC
Commits pushed to 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