D-Programming-Language/dmd — pull request #2106 by donc (2013-05-31 07:43:30+00:00)
Title: Never run CTFE on template alias parameters

This is the most important pull request of my major project to unify optimize(WANTinterpret) and CTFE.
A crucial issue is to make sure that optimize(WANTinterpret) is called only when a value is required.

Up to now, optimize(WANTinterpret) has always been called, even for types, tuples, and aliases. If it can't interpret it, it just returns it unchanged.
This pull request identifies all the situations where a template parameter might be a alias or a type, and doesn't try to interpret it in that case. Only when it KNOWS that it needs a value, should it invoke CTFE.

Apart from the benefit for CTFE, this change also makes template,c much easier to understand. It means that optimize(WANTinterpret) no longer plays a role in determining if a template parameter is an alias, or not. I don't think anybody understood exactly what it was doing, before. It certainly took me a long time to figure it out.