[Issue 2779] alias this + tuple expansion on function call doesn't work

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jul 22 07:51:02 PDT 2011


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



--- Comment #3 from Kenji Hara <k.hara.pg at gmail.com> 2011-07-22 07:50:59 PDT ---
(In reply to comment #2)
> I think it's best to leave things as they are and close this. Automatic
> expansion is a bad thing. Consider for example:
> 
> struct Tuple(T...) {
>     T data;
>     alias data this;
> }
> 
> void doStuff(Tuple!(uint, float) t) {}
> void doStuff(uint a, float b) {}
>
> In this case we need to introduce a new rule that says the tuple should NOT be
> expanded if there's a matching function, or a new rule that makes the call
> ambiguous.

This case does not introduce ambiguous. Alias this lookup will run only when
original type matching fails. So 1st doStuff will match.
We can treat tuple expansion on function arguments based on alias this rule,
not any new rule.

My patch also work like it.
https://github.com/D-Programming-Language/dmd/pull/74/files#L7R144
func6_22 call with Tup!(int, string) object matches 2nd overload version.

-- 
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