[Issue 6557] Inplace enum literals

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Aug 26 16:31:41 PDT 2011


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



--- Comment #2 from bearophile_hugs at eml.cc 2011-08-26 16:31:38 PDT ---
(In reply to comment #1)

> In following case, what does foo receive as arg?
> 
> void main()
> {
>     typeof(foo.a) E;
>     E a = foo.b;
>     foo(a);   // == foo(foo.a) or foo(foo.b) ?
> }

Thank you for finding this problem. I think that's a quite uncommon case, it's
a bug of the programmer. So this bad corner case is not enough to kill the
whole idea. In this case of actual ambiguity I think D has to act like in this
case:


struct Foo {
    int x;
}
void main() {
    int x;
    Foo f;
    with (f)
        x++; // line 8, error
    with (f) {} // no error here, no actual ambiguity
}

test.d(8): Error: with symbol test.Foo.x is shadowing local symbol test.main.x



void foo(enum {a, b} arg) {}
void main() {
    auto a = foo.b;
    foo(a); // Error: ambiguity...
}

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