[Issue 9999] Integer literal 0 and 1 should prefer integer type in overload resolution

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Nov 4 16:35:06 PST 2014


https://issues.dlang.org/show_bug.cgi?id=9999

hsteoh at quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hsteoh at quickfur.ath.cx

--- Comment #11 from hsteoh at quickfur.ath.cx ---
IMO, we should prohibit implicit conversion from int to bool. The issue is that
the mapping 0 -> false, 1 -> true is essentially an arbitrary one. Logically
speaking, bool consists of two values, true and false. It's already
questionable why they should respectively map to 1 and 0, and even more
questionable that this mapping is done *implicitly*. An integer expression
should definitely prefer binding to int over bool, even with VRP. If the user
actually intended the conversion, that intent ought to be documented with an
explicit cast.

--


More information about the Digitalmars-d-bugs mailing list