Skip to content

Synthesized name clashes with existing vars in scope #1572

@tamlin-mike

Description

@tamlin-mike

LINQ-generation needs to look at all vars in scope when synthesizing a name, not only ilSpy-generated names, but also parameters. If not, you can end up with something like

void fn(int var1) {
 ... = from var1 in whatever ...
}

where the second var1 is a ilSpy-synthesized name, intended to be unique, making the code uncompilable.

Since this is yet another instance of the same problem that has been observed more than once, perhaps the code synthesizing a new local name should be refactored into a single place, to solve this problem once and for all?

EDIT: Upon close inspection it's not only a LINQ problem, it pops up for nested vars even when turning off LINQ-generation, such as in parameter names for nested lambda's.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions