[Issue 8374] One missed array literal interpretation as int[2]

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jul 10 17:49:57 PDT 2012


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



--- Comment #3 from bearophile_hugs at eml.cc 2012-07-10 17:49:56 PDT ---
(In reply to comment #1)
> The type of
> 
>    [1,2]
> 
> is int[], not int[2].

Usually in my bug reports I add some cases where the code works, to avoid
troubles like this one.


This works:


struct Foo {
    int[2] bar;
}
int[2] spam() {
    Foo* x;
    return true ? x.bar : [10, 20];
}
void main() {}


This too works:


struct Foo {
    int[2] bar;
}
const(int[2]) spam() {
    const Foo* x;
    const(int[2]) r = true ? x.bar : [10, 20];
    return r;
}
void main() {}

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