https://issues.dlang.org/show_bug.cgi?id=18038

Simen Kjaeraas <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |[email protected]
         Resolution|---                         |INVALID

--- Comment #1 from Simen Kjaeraas <[email protected]> ---
This is intended behavior.

https://dlang.org/spec/statement.html#WithStatement:

5. Use of with object symbols that shadow local symbols with the same
identifier are not allowed. This is to reduce the risk of inadvertant breakage
of with statements when new members are added to the object declaration.

struct S
{
    float x;
}

void main()
{
    int x;
    S s;
    with (s)
    {
        x++;  // error, shadows the int x declaration
    }
}

--

Reply via email to