struct Foo { enum bool BAR = is (typeof({}())); // Error: static assert (0 == 1) is false static assert (BAR == is (typeof({}()))); }
PATCH: in FuncDeclaration::semantic3(), it's forbidden to use function literals as class members. But, it should be OK to use them inside a typeof() expression. ---------- Index: func.c =================================================================== --- func.c (revision 335) +++ func.c (working copy) @@ -789,14 +789,14 @@ if (ad) { VarDeclaration *v; - if (isFuncLiteralDeclaration() && isNested()) + if (isFuncLiteralDeclaration() && isNested() && !sc->intypeof) { error("literals cannot be class members"); return; } else { - assert(!isNested()); // can't be both member and nested + assert(!isNested() || sc->intypeof); // can't be both member and nested assert(ad->handle); Type *thandle = ad->handle; #if STRUCTTHISREF
changeset 371
(In reply to comment #2) > changeset 371 http://www.dsource.org/projects/dmd/changeset/371
Fixed dmd 1.057 and 2.041