[Issue 18038] Error: with symbol is shadowing local symbol
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Dec 6 12:03:36 UTC 2017
https://issues.dlang.org/show_bug.cgi?id=18038
Simen Kjaeraas <simen.kjaras at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |simen.kjaras at gmail.com
Resolution|--- |INVALID
--- Comment #1 from Simen Kjaeraas <simen.kjaras at gmail.com> ---
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
}
}
--
More information about the Digitalmars-d-bugs
mailing list