Bug 3450 – incorrect result for is (typeof({ ... }())) inside a struct
Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2009-10-29T08:19:00Z
Last change time
2015-06-09T01:26:56Z
Keywords
patch, wrong-code
Assigned to
nobody
Creator
kamaboco
Comments
Comment #0 by kamaboco — 2009-10-29T08:19:37Z
struct Foo
{
enum bool BAR = is (typeof({}()));
// Error: static assert (0 == 1) is false
static assert (BAR == is (typeof({}())));
}
Comment #1 by clugdbug — 2010-01-16T23:30:16Z
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