Bug 11747 – Better error message with @disabled toString

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-12-15T03:04:33Z
Last change time
2020-03-21T03:56:35Z
Keywords
pull
Assigned to
No Owner
Creator
bearophile_hugs
Depends on
18149

Comments

Comment #0 by bearophile_hugs — 2013-12-15T03:04:33Z
A low priority enhancement suggestion. A way to disallow the printing of a struct is to use @disable on its toString: struct Foo { @disable string toString(); } void main() { import std.stdio; Foo f; writeln(f); } But the missing function is only detected at link time (dmd 2.065alpha): test2.obj(test2) Error 42: Symbol Undefined _D5test23Foo8toStringMFZAya So perhaps it's better to add to write a template constraint that verifies toString is not @disabled, to catch the problem at compile-time.
Comment #1 by b2.temp — 2018-01-13T19:20:30Z
I plan to fix this using use this new feature https://github.com/dlang/dmd/pull/7569
Comment #2 by b2.temp — 2018-01-22T09:07:16Z
Comment #3 by github-bugzilla — 2018-01-27T03:43:28Z
Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/4f67cdf115f1034c2676ee2f1ae70ae05efcd805 fix issue 11747 - Better error message with @disabled toString https://github.com/dlang/phobos/commit/b676da0a98440fd5935d10d1f302da8b4da4688c Merge pull request #6047 from BBasile/issue-11747 fix issue 11747 - Better error message with @disabled toString merged-on-behalf-of: H. S. Teoh <[email protected]>