Can we make auto return type inference a little more lax?
Robert Clipsham
robert at octarineparrot.com
Tue May 17 14:00:13 PDT 2011
On 17/05/2011 04:40, Andrej Mitrovic wrote:
> auto foo()
> {
> if (1)
> {
> return [0, 0];
> }
> else
> {
> size_t one;
> size_t two;
>
> return [one, two];
> }
> }
>
> void main(){ }
>
> Error: mismatched function return type inference of
> uint[] and int[]
>
> Surely the compiler can figure out a common type for these two when literals are involved.
I haven't tested, but make the first array [0u, 0u], that should work,
as a work around. Make a bug report for this (maybe a patch if you feel
up to it? :D).
--
Robert
http://octarineparrot.com/
More information about the Digitalmars-d-learn
mailing list