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
I suspect this is a known issue due to the struct being empty. That said, I'm not sure why this would only affect an empty struct defined in metadata (as opposed to the same compilation/source).
Tagging @gafter to confirm.
This is an intentional behavior. See also #30194 where we propose to fix this intentionally broken behavior. The struct contains only a private (in this case compiler-generated) field of a reference type, so (due to the intentional behavior of the compiler) it is ignored for the purposes of definite assignment when imported from an assembly.
Version Used:
Visual Studio 16.2.5
MSBuild 16.2.37902+b5aaefc9f
csc.exe 3.2.1-beta4-19408-03
Steps to Reproduce:
You need two assemblies for this,
Lib
andApp
, whereApp
referencesLib
.Expected Behavior:
error CS0165: Use of unassigned local variable 'notNull'
Actual Behavior:
The code compiles.
Additional information:
If you make any of the following changes, the code stops compiling and the expected error appears:
string
to, let's say,int
You can check out a solution that illustrates all these permutations and their effect on the compiler behavior here.
The text was updated successfully, but these errors were encountered: