[Issue 2614] auto + templated structs = unhelpful error messages

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Mar 1 02:38:29 PST 2009


http://d.puremagic.com/issues/show_bug.cgi?id=2614





------- Comment #3 from bugzilla at digitalmars.com  2009-03-01 04:38 -------
The problem here is that S!(int)(42) can be either a template followed by (42),
or a function template with argument list (42). The compiler cannot tell. So
first it tries the former, and it silently fails (due to the wrong_code). Then,
it figures it must be a function template, and tries that. That fails too,
hence the error message you see.

The reason:

S!(int) s = S!(int)(42);

gives a more correct message is the left S!(int) type is compiled first, and by
the syntax the compiler knows it's not a function template, so instead of
silently failing it verbosely fails.

So what to do if both tries at instantiating it fail? Print the first error
message, or the second? One will not make sense.


-- 



More information about the Digitalmars-d-bugs mailing list