void main() {
void fun(T)() {}
int x = cast(int)fun;
}
----
fun(T)
Internal error: e2ir.c 644
Comment #1 by clugdbug — 2009-10-21T07:16:59Z
Oops, local template functions seem to be legal in D2. I didn't realize that. So this is valid code.
Comment #2 by clugdbug — 2009-10-22T01:35:53Z
Applies to D1 as well. Doesn't require nested templates. Test case (ICEs even on DMD0.175):
---
void fun(T=int)(int w, int z) {}
void main() {
auto x = cast(void function(int, int))fun;
}
---
Root cause: Shouldn't be able to cast from void to anything else (except void).
This patch also moves some error messages from e2ir into the front-end where they belong.
-----
PATCH: expression.c, line 7423 (DMD 2.035, svn rev215):
if (!to->equals(e1->type))
{
e = op_overload(sc);
if (e)
{
return e->implicitCastTo(sc, to);
}
+ /* Cannot cast from void to anything other than void
+ */
+ if (e1->type == Type::tvoid) {
+ error("'%s' is void and cannot be cast to %s", e1->toChars(), to->toChars());
+ return new ErrorExp();
+ }
}
Type *t1b = e1->type->toBasetype();
Type *tob = to->toBasetype();
Comment #3 by leandro.lucarella — 2009-10-31T22:47:13Z