[Issue 7549] typeof of overloaded function picks the lexically first one

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Feb 19 15:25:44 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=7549



--- Comment #1 from Kenji Hara <k.hara.pg at gmail.com> 2012-02-19 15:25:42 PST ---
I think typeof(overloadset):=void is not good.
Because, in this case, calculating typeof(foo) to void is valid by translating
foo to foo() first.

So introducing new ambiguous function type instead of void is much better.
(My idea is here: https://github.com/D-Programming-Language/dmd/pull/71)

void foo();
void foo(int);
static assert(is(typeof(foo) == void));  // without -property switch
static if (is(typeof(foo) R)) {} // evaluated to false with -property switch,
                                 // because R is ambiguous type, not exact
type.
@property int foo();
@property void foo(int);
static assert(is(typeof(foo) == int));  // always true

void foo(int);
void foo(long);
static assert(is(typeof(foo)));  // always true, because foo has some type,
                                 // even if it is ambiguous type.
static if (is(typeof(foo) R)) {} // evaluated to false, 
                                 // because R is ambiguous type, not exact
type.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list