On 9/5/13, Timothee Cour <thelastmamm...@gmail.com> wrote:
> So would it be possible to detect such kind of errors (ie CT error
> regardless of template params) without having to instantiate the template?

How would you semantically analyze the following without instantiating it?:

-----
template T(X)
{
    enum T = X.foo;
}
-----

Note how the above can be both valid and invalid based on the template
parameters:

-----
class C
{
    enum int foo = 1;
}

class D
{
    int foo = 1;
}

void main()
{
    enum foo = T!C;  // ok
    enum foo = T!D;  // fail
}
-----

There's so much context-dependent semantics in a template that eager
semantic analysis of templates which haven't been instantiated would
be limited to work for only very simple templates. So I don't think it
would be worth even trying to analyze without instantiating.

Also, I think it would likely be extremely hard to implement in the
compiler, and could possible lead to false-positives (compiles) or
false-negatives (doesn't compile) cases.

And finally, compile times would literally explode with eager semantic analysis.

Reply via email to