[Issue 14249] Loose error check for incorrect template mixin

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Mar 5 05:50:24 PST 2015


https://issues.dlang.org/show_bug.cgi?id=14249

Kenji Hara <k.hara.pg at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic

--- Comment #1 from Kenji Hara <k.hara.pg at gmail.com> ---
And, the error diagnostic for other invalid cases is not good.

mixin template Mix()
{
    shared static this() {}
//  shared static ~this() {}
    static this() {}
//  static ~this() {}
//  unittest {}
    invariant {}
    alias a this;
    new(size_t sz) { return null; }
    delete(void* p) { }
    this(int) {}
    this(this) {}
    ~this() {}
    union { int x; double y; }
}
void main()
{
    mixin Mix!();
}

test.d(8): Error: function test.main.Mix!().__invariant6 invariants are only
for struct/union/class definitions
test.d(9): Error: alias this test.main.Mix!().__anonymous alias this can only
appear in struct or class declaration, not main
test.d(10): Error: allocator test.main.Mix!().new new allocators only are for
class or struct definitions
test.d(11): Error: deallocator test.main.Mix!().delete new allocators only are
for class or struct definitions
test.d(12): Error: constructor test.main.Mix!().this constructors are only for
class or struct definitions
test.d(13): Error: function test.main.Mix!().__postblit post blits are only for
struct/union definitions, not function main
test.d(14): Error: destructor test.main.Mix!().~this destructors are only for
class/struct/union definitions, not function main
test.d(15): Error: anonymous union __anonymous can only be a part of an
aggregate
test.d(3): Error: function test.main.Mix!()._sharedStaticCtor4 static
constructor can only be member of struct/class/module, not function main
test.d(5): Error: function test.main.Mix!()._staticCtor5 static constructor can
only be member of struct/class/module, not function main
test.d(19): Error: mixin test.main.Mix!() error instantiating

--


More information about the Digitalmars-d-bugs mailing list