digitalmars.D - is Expression, Type Identifier : TypeSpecialization
- Andrej Mitrovic (24/24) Jun 23 2010 Hi,
- Trass3r (1/8) Jun 24 2010 If it works without the aliases this is another strange alias bug.
- Andrej Mitrovic (4/14) Jun 24 2010 Do you mean the "alias one ONE; alias two TWO;" statements, or the missi...
- Trass3r (14/14) Jun 24 2010 You are right.
Hi, On the expressions page, http://www.digitalmars.com/d/2.0/expression.html under section 5: "is ( Type Identifier : TypeSpecialization )" it states: "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." The following prints 'test': class one { } class two : one { } alias one ONE; alias two TWO; static if ( is(TWO : ONE) ) writeln("test"); But if I add an Identifier T, the 'is' expression evaluates to 0, writeln is not executed: class one { } class two : one { } alias one ONE; alias two TWO; static if ( is(TWO T : ONE) ) writeln("test"); Is this a bug, or am I doing it wrong?
Jun 23 2010
class one { } class two : one { } alias one ONE; alias two TWO; static if ( is(TWO T : ONE) ) writeln("test"); Is this a bug, or am I doing it wrong?If it works without the aliases this is another strange alias bug.
Jun 24 2010
Trass3r Wrote:Do you mean the "alias one ONE; alias two TWO;" statements, or the missing T alias? In the first case, If I comment out the two alias statements, it will still compile. But that's not a bug, it's still syntactically correct (in that case "ONE" and "TWO" don't exist, but the compiler won't complain about it). In the second case, the aliased identifier doesn't need to be there unless we want to use it, see form #2 of the is expressions near the bottom of the page: http://www.digitalmars.com/d/2.0/expression.htmlclass one { } class two : one { } alias one ONE; alias two TWO; static if ( is(TWO T : ONE) ) writeln("test"); Is this a bug, or am I doing it wrong?If it works without the aliases this is another strange alias bug.
Jun 24 2010
You are right. Even this doesn't work: import std.stdio; class one { } class two : one { } void main() { static if ( is(two T : one) ) writeln("test"); } Additionally it's really strange dmd doesn't complain about TWO and ONE if the aliases are omitted. Seems like two distinct bugs to me. File bug reports.
Jun 24 2010