void main() { void fun(T)() {} int x = cast(int)fun; } ---- fun(T) Internal error: e2ir.c 644
Oops, local template functions seem to be legal in D2. I didn't realize that. So this is valid code.
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();
SVN commit: http://www.dsource.org/projects/dmd/changeset/232
Fixed dmd 1.051 and 2.036
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル