Bug 11481 – Clearly note all explicit casts are forwarded to `alias this` if there is no `opCast`

Status
RESOLVED
Resolution
INVALID
Severity
major
Priority
P2
Component
dlang.org
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-11-09T05:39:36Z
Last change time
2018-11-23T19:24:50Z
Keywords
spec
Assigned to
No Owner
Creator
Denis Shelomovskii

Comments

Comment #0 by verylonglogin.reg — 2013-11-09T05:39:36Z
People tend to think explicit cast behaves as no-op if there is an implicit one. Documentation must clearly note it's wrong and `opCast` is tried to be called. Also a list of operations rewritten as explicit cast like `if(someStruct)` must be provided as people tend to forget invisible explicit casts exist. Appendix: * Filed invalid bugs because of this: Issue 3537, Issue 6777, Issue 7985, Issue 9151. * Lockup mechanics explanation by Kenji Hara: Comment 2 of Issue 11161.
Comment #1 by timon.gehr — 2013-11-09T06:39:42Z
(In reply to comment #0) > People tend to think explicit cast behaves as no-op if there is an implicit > one. Documentation must clearly note it's wrong and `opCast` is tried to be > called. > > Also a list of operations rewritten as explicit cast like `if(someStruct)` must > be provided as people tend to forget invisible explicit casts exist. > > Appendix: > * Filed invalid bugs because of this: Issue 3537, Issue 6777, Issue 7985, Issue > 9151. Issue 9151 is the only instance of this. Simply adding an alias this must not result in hijacking, so the current behaviour is unacceptable for the other issues. > * Lockup mechanics explanation by Kenji Hara: Comment 2 of Issue 11161. How exactly DMD derives unreasonable behaviour is not relevant for answering the question whether the behaviour is reasonable.