digitalmars.D - is expression: library reference
- Morlan (18/18) Mar 24 2011 The library refernce has the following text concerning the is expression...
- Jonathan M Davis (2/26) Mar 24 2011 Create a bug report for it: http://d.puremagic.com/issues/
The library refernce has the following text concerning the is expression: 5. is ( Type Identifier : TypeSpecialization ) The condition is satisfied if Type is the same as TypeSpecialization, or if Type is a class and TypeSpecialization is a base class or base interface of it. The Identifier is declared to be either an alias of the TypeSpecialization or, if TypeSpecialization is dependent on Identifier, the deduced type. However, the following code fragment will print "short is int" and "short" which seems to contradict the above description. static if(is(short T: int)){ writeln("short is int"); writeln(typeid(T)); }else{ writeln("short is not int"); } The observed behaviour is such that short T: int means that short can be implicitely converted to int and T is defined to mean "short" rather than "int". Thus T is not defined to mean TypeSpecialization but Type. This discrepancy should be corrected.
Mar 24 2011
The library refernce has the following text concerning the is expression: 5. is ( Type Identifier : TypeSpecialization ) The condition is satisfied if Type is the same as TypeSpecialization, or if Type is a class and TypeSpecialization is a base class or base interface of it. The Identifier is declared to be either an alias of the TypeSpecialization or, if TypeSpecialization is dependent on Identifier, the deduced type. However, the following code fragment will print "short is int" and "short" which seems to contradict the above description. static if(is(short T: int)){ writeln("short is int"); writeln(typeid(T)); }else{ writeln("short is not int"); } The observed behaviour is such that short T: int means that short can be implicitely converted to int and T is defined to mean "short" rather than "int". Thus T is not defined to mean TypeSpecialization but Type. This discrepancy should be corrected.Create a bug report for it: http://d.puremagic.com/issues/ - Jonathan M Davis
Mar 24 2011