Historically, when developing in .Net I could not duplicate the name of variable in nested scope. However, after recently updating Visual Studio 2019 to version 16.4.2 I have noticed that variable names can be duplicated in nested scope.
For example:
var test = "hello";
Console.WriteLine(test);
var things = new []{"one", "two", "three"};
things.Select(test => // <- test is duplicated here, normally this breaks compilation
{
Console.WriteLine(test);
return test;
}).ToList();
// output:
// hello
// one
// two
// three
https://dotnetfiddle.net/h85BK4
Why is this suddenly allowed?
Follow up question: If this is a new language "feature", is there a way to configure Visual Studio to continue to break when a variable is duplicated in nested scope?