Skip to content

Commit

Permalink
Handle case where arity is 0.
Browse files Browse the repository at this point in the history
  • Loading branch information
GGG-KILLER committed Jan 22, 2024
1 parent 86eadf8 commit 5d46aec
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions Tsu.TreeSourceGen/src/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
writer.Write(arg);
writer.WriteLine(" is not null)");
writer.Indent++;
writer.Write("return ");
if (visitor.Arity > 0)
writer.Write("return ");
writer.Write(arg);
writer.Write(".Accept(");
writer.Write("this");
Expand All @@ -183,8 +184,11 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
}
writer.WriteLine(");");

writer.WriteLine();
writer.WriteLine("return default;");
if (visitor.Arity > 0)
{
writer.WriteLine();
writer.WriteLine("return default;");
}
writer.Indent--;
writer.Write('}');
}
Expand All @@ -211,7 +215,16 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
writer.Write(" arg");
writer.Write(idx);
}
writer.WriteLine(") => default;");
if (visitor.Arity > 0)
{
writer.WriteLine(") => default;");
}
else
{
writer.WriteLine(')');
writer.WriteLine('{');
writer.WriteLine('}');
}
}

foreach (var node in tree.Nodes)
Expand Down

0 comments on commit 5d46aec

Please sign in to comment.