Incorrect error using static local function
I have several local functions which do not capture any state, and which Visual Studio tells me can be converted to static local functions.
In most cases, R# seems happy with this. However, in one specific local function, R# incorrectly generates an error: "A static local function cannot contain a reference to 'this' or 'base'".
There is no such reference in the function. The code compiles and works as expected.
public IReadOnlyList<ChartItem> LoadChart(...)
{
...
static IReadOnlyList<ChartItem> SumFirms(IEnumerable<(decimal b0, decimal b1, decimal b2, decimal b3, decimal b4)> firmResults)
{
decimal b0 = 0, b1 = 0, b2 = 0, b3 = 0, b4 = 0;
foreach (var item in firmResults)
{
b0 += item.b0;
b1 += item.b1;
b2 += item.b2;
b3 += item.b3;
b4 += item.b4;
}
return new List<ChartItem>
{
new ChartItem
{
Label = "Band 1",
Color = new ChartColor(128, 198, 85),
Value = b0,
},
new ChartItem
{
Label = "Band 2",
Color = new ChartColor(245, 185, 63),
Value = b1,
},
new ChartItem
{
Label = "Band 3",
Color = new ChartColor(237, 129, 52),
Value = b2,
},
new ChartItem
{
Label = "Band 4",
Color = new ChartColor(233, 97, 46),
Value = b3,
},
new ChartItem
{
Label = "Band 5",
Color = new ChartColor(255, 46, 46),
Value = b4,
},
};
}
}
VS2019 v16.3.6
R# 2019.2.3
Please sign in to leave a comment.
Hello Richard,
Thank you for the provided feedback.
I've filed correspondent bug report - https://youtrack.jetbrains.com/issue/RSRP-476804.
Please feel free to comment or vote for it.
Thank you.