You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CS0170: Use of possibly unassigned field '_dummyPrimitive'
Expected Behavior:
Roslyn should report that it's impossible to use DoSmth() local function before initializing guid local variable. Without referring to any of private fields in the Guid type.
Actual Behavior:
Class1.cs(7,18): error CS0170: Use of possibly unassigned field '_dummyPrimitive'
So, not only it doesn't reference the actual variable that's not initialized, it also mentions _dummyPrimitive, a name of the synthetic field in the corresponding reference assembly and not a real field from System.Guid (I assume).
Imagine what will happen if you are working in a function with a dozen of variables, and Roslyn tells you that some of them are not initialized, using an unfamiliar field name when telling that. The error is quite confusing.
The text was updated successfully, but these errors were encountered:
ForNeVeR
changed the title
Bad error report when using uninitialized variable in a local function
Bad error report when using uninitialized variable in a local function: "Use of possibly unassigned field '_dummyPrimitive'"
Dec 30, 2024
ForNeVeR
changed the title
Bad error report when using uninitialized variable in a local function: "Use of possibly unassigned field '_dummyPrimitive'"
Unclear error report when using uninitialized variable in a local function: "Use of possibly unassigned field '_dummyPrimitive'"
Dec 31, 2024
Version Used:
Steps to Reproduce:
Write the following program (
dotnet new classlib
,<TargetFramework>net9.0</TargetFramework>
).Diagnostic Id:
Expected Behavior:
Roslyn should report that it's impossible to use
DoSmth()
local function before initializingguid
local variable. Without referring to any of private fields in theGuid
type.Actual Behavior:
So, not only it doesn't reference the actual variable that's not initialized, it also mentions
_dummyPrimitive
, a name of the synthetic field in the corresponding reference assembly and not a real field fromSystem.Guid
(I assume).Imagine what will happen if you are working in a function with a dozen of variables, and Roslyn tells you that some of them are not initialized, using an unfamiliar field name when telling that. The error is quite confusing.
The text was updated successfully, but these errors were encountered: