The definite assignment rules implemented by previous compilers for dynamic expressions allowed some cases of code that could result in variables being read that are not definitely assigned. See https://github.com/dotnet/roslyn/issues/4509 for one report of this.
The following (twisted) program demonstrates that "fixing" this issue would introduce a situation in which the compiler would allow reading an uninitialized variable.
```cs
usingSystem;
namespaceConsoleApp
{
classProgram
{
staticvoidMain(string[]args)
{
stringval="unassigned";
if(Api1()&&Api2(outval)&&UseVal(val))
{
Console.WriteLine(val);
}
}
staticdynamicApi1()
{
returnnewWaffle();
}
staticboolApi2(outstringval)
{
Console.WriteLine("Assigning to val");
val="assigned";
returntrue;
}
staticdynamicUseVal(stringval)
{
Console.WriteLine($"Using val == {val}");
returntrue;
}
}
classWaffle
{
intcount=0;
publicstaticimplicitoperatorbool(Wafflew)
{
try
{
returnw.count!=0;
}
finally
{
w.count++;
}
}
}
}
```
The output of this program is
```none
Using val == unassigned
unassigned
```
Because of this possibility the compiler must not allow this program to be compiled if `val` has no initial value. Previous versions of the compiler (prior to VS2015) allowed this program to compile even if val has no initial value. Roslyn now diagnoses this attempt to read a possibly uninitialized variable.