| Thread overview | |||||
|---|---|---|---|---|---|
|
June 17, 2012 UFCS call and regular call behaves differently with alias parameter | ||||
|---|---|---|---|---|
| ||||
The following code shows that depending on how a function is called, UFCS or regular syntax, the type of T is inferred differently. If I remove the alias parameter the code behaves as expected.
string foo (alias p, T) (T t)
{
return typeof(t).stringof;
}
void main ()
{
string[string] aa;
auto x = foo!(3 > 4)(aa);
auto y = aa.foo!(3 > 4);
assert(x == y);
writeln("x=", x);
writeln("y=", y);
}
In the above code the assert is triggered. If I remove the assert the code prints:
x=string[string]
y=AssociativeArray!(string,string)
--
/Jacob Carlborg
| ||||
June 17, 2012 Re: UFCS call and regular call behaves differently with alias parameter | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | On 06/17/2012 06:14 PM, Jacob Carlborg wrote:
> The following code shows that depending on how a function is called,
> UFCS or regular syntax, the type of T is inferred differently. If I
> remove the alias parameter the code behaves as expected.
>
> string foo (alias p, T) (T t)
> {
> return typeof(t).stringof;
> }
>
> void main ()
> {
> string[string] aa;
>
> auto x = foo!(3 > 4)(aa);
> auto y = aa.foo!(3 > 4);
>
> assert(x == y);
>
> writeln("x=", x);
> writeln("y=", y);
> }
>
> In the above code the assert is triggered. If I remove the assert the
> code prints:
>
> x=string[string]
> y=AssociativeArray!(string,string)
>
> --
> /Jacob Carlborg
This should go straight to the bug tracker. User code is not supposed to see the AssociativeArray rewrite.
| |||
June 17, 2012 Re: UFCS call and regular call behaves differently with alias parameter | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Timon Gehr | On 2012-06-17 18:46, Timon Gehr wrote: > This should go straight to the bug tracker. User code is not supposed to > see the AssociativeArray rewrite. Done: http://d.puremagic.com/issues/show_bug.cgi?id=8259 -- /Jacob Carlborg | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply