1 matches bool, 2 matches long

Ali Çehreli acehreli at yahoo.com
Fri Apr 26 10:25:41 PDT 2013


On 04/26/2013 12:03 AM, Maxim Fomin wrote:
 > On Friday, 26 April 2013 at 02:13:03 UTC, Ali Çehreli wrote:
 >> On 04/25/2013 06:44 PM, Maxim Fomin wrote:
 >>
 >> > On Thursday, 25 April 2013 at 21:05:43 UTC, Ali Çehreli wrote:
 >>
 >> > Looks like value range propagation bug because 1 is integer
 >> literal and
 >> > should be converted to long. There is no way for 1 to be
 >> converted to
 >> > bool here
 >>
 >> That special conversion rule of literal 0 and literal 1 being
 >> implicitly convertible to false and true gets in the way.
 >>
 >> > (from TDPL long is below int and it is the shortest way, value
 >> > range propagation can work upwards, but the path would be
 >> longer).
 >> Ali
 >
 > Sorry but I am not aware of how 1 is converted to bool here.
 > True, that 1 is convertible to true,

Yes, through an implicit conversion.

 > but here there is function
 > with long parameter.

Since the type of literal 1 is int, calling foo(long) would require an 
implicit conversion as well: from int to long.

In the end, both functions are candidates because they both accept 1 by 
one implicit conversion.

Ali



More information about the Digitalmars-d mailing list