monarch_dodra:

From what I can observe, the compiler resolves the ambiguity by chosing the first match in terms of scope. Eg, there's shadowing. From my previous code:



with (t)
{
    writeln(k); //prints t.k
    with(s)
    {
        writeln(k); //prints s.k: it is now shadowing t.k


A reduced test case:

void main() {
    static struct S { int k = 1; }
    static struct T { int k = 2; }
    S s;
    T t;
    with (t) {
        assert(k == 2);
        with(s) {
            assert(k == 1);
        }
    }
}


Is this a failure (a bug) of the anti-hijacking mechanism of with()?

Bye,
bearophile

Reply via email to