D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7123 - static assert(is(typeof(toDelegate(&main)))) is false
Summary: static assert(is(typeof(toDelegate(&main)))) is false
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: patch, wrong-code
Depends on:
Blocks:
 
Reported: 2011-12-17 00:24 UTC by SHOO
Modified: 2011-12-18 20:22 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description SHOO 2011-12-17 00:24:30 UTC
This code should be compilable.

import std.functional;
void main()
{
	version(Workaround) typeof(toDelegate(&main)) dgDummy; // <- Code is compilable if this line is enabled.
	static assert(is(typeof(toDelegate(&main)))); // NG: false
}
Comment 1 Kenji Hara 2011-12-17 04:12:01 UTC
Reduced test case:

private struct DelegateFaker(F)
{
    template GeneratingPolicy() {}
    enum WITH_BASE_CLASS = __traits(hasMember, GeneratingPolicy!(), "x");
}
auto toDelegate(F)(F fp)
{
    alias DelegateFaker!F Faker;
}
void main()
{
    version(pass)
    {
        pragma(msg, typeof(toDelegate(&main)));
        static assert(is(typeof(toDelegate(&main))));
    }
    else
    {
        static assert(is(typeof(toDelegate(&main))));
    }
}