Bug 16444 – Less noisy error messages if built-in method is @disable (e.g. opAssign)

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2016-08-29T15:50:05Z
Last change time
2024-12-13T18:49:52Z
Keywords
diagnostic
Assigned to
No Owner
Creator
Seb
Moved to GitHub: dmd#19183 →

Comments

Comment #0 by greensunny12 — 2016-08-29T15:50:05Z
When a builtin-in method like opAssign is disabled, the error messages are quite noisy: struct A { @disable void opAssign(Other)(Other other); } pure nothrow @safe @nogc unittest { A a; a = A(); } foo.d(16): Error: function foo.A.opAssign!(A).opAssign is not callable because it is annotated with @disable foo.d(16): Error: pure function 'foo.__unittestL13_1' cannot call impure function 'foo.A.opAssign!(A).opAssign' foo.d(16): Error: safe function 'foo.__unittestL13_1' cannot call system function 'foo.A.opAssign!(A).opAssign' foo.d(16): Error: @nogc function 'foo.__unittestL13_1' cannot call non-@nogc function 'foo.A.opAssign!(A).opAssign' foo.d(16): Error: function 'foo.A.opAssign!(A).opAssign' is not nothrow foo.d(13): Error: function 'foo.__unittestL13_1' is nothrow yet may throw There is a trick that is used in https://github.com/dlang/phobos/pull/4755, one can simply annotate the disabled function with all attributes: struct B { pure nothrow @safe @nogc @disable void opAssign(Other)(Other other); } pure nothrow @safe @nogc unittest { B b; b = B(); } foo.d(16): Error: function foo.B.opAssign!(B).opAssign is not callable because it is annotated with @disable
Comment #1 by robert.schadek — 2024-12-13T18:49:52Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19183 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB