Skip to content

Commit

Permalink
Require definite assignment of all fields if struct includes any fiel…
Browse files Browse the repository at this point in the history
…d initializers
  • Loading branch information
cston committed Nov 22, 2021
1 parent 5b20a71 commit a08d57f
Show file tree
Hide file tree
Showing 2 changed files with 526 additions and 173 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static BoundBlock Rewrite(
if (method.ReturnsVoid || method.IsIterator || method.IsAsyncEffectivelyReturningTask(compilation))
{
// we don't analyze synthesized void methods.
if ((method.IsImplicitlyDeclared && !method.IsScriptInitializer) ||
if ((method.IsImplicitlyDeclared && !method.IsScriptInitializer && (!method.IsParameterlessConstructor() || method.IsDefaultValueTypeConstructor(requireZeroInit: true))) ||
Analyze(compilation, method, block, diagnostics))
{
block = AppendImplicitReturn(block, method, originalBodyNested);
Expand Down
Loading

0 comments on commit a08d57f

Please sign in to comment.