On Thu, 15 Jan 2015 00:05:30 +0000 Xinok via Digitalmars-d <[email protected]> wrote:
> Well, the error the compiler prints is:
>
> Error: forward reference to inferred return type of function call
> 'correct'
>
> I played with it a bit and it seems to deduce a common type from
> all the return statements, which would be more in the style of D
> anyways (take type deduction for arrays). For example, the
> following code prints "float" rather than "int":
>
> import std.stdio;
>
> auto one(int i)
> {
> if(i > 0)
> return cast(int)i;
> else
> return cast(float)i;
> }
>
> void main()
> {
> writeln(typeid(typeof(one(10))));
> }
i remember that there was some discussion about this, but it's all i
can remember about it. ;-)
there were some inconsistencies with deducing return type, AFAIR, but i
don't remember if it leads to some fixes or not. if ony i wasn't so
lazy and take some notes...
signature.asc
Description: PGP signature
