Skip to content

Commit

Permalink
Bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
LPeter1997 committed Oct 23, 2023
1 parent add3a88 commit ccfd852
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/Draco.Compiler/Internal/Syntax/Formatting/Formatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ public override SyntaxNode VisitBlockFunctionBody(BlockFunctionBodySyntax node)
Unindent,
node.CloseBrace));

public override SyntaxNode VisitExpressionStatement(ExpressionStatementSyntax node) => node.Update(this.AppendSequence(
node.Expression,
node.Semicolon,
Newline));

public override SyntaxNode VisitGroupingExpression(GroupingExpressionSyntax node) =>
node.Update(this.AppendSequence(node.OpenParen, node.Expression, node.CloseParen));

Expand Down
8 changes: 7 additions & 1 deletion src/Draco.SourceGeneration/Templates/GreenSyntaxTree.sbncs
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,16 @@ namespace Draco.Compiler.Internal.Syntax;
{
throw new System.ArgumentOutOfRangeException(
nameof(children),
"the sequence must contain the exact amount of children");
"the sequence contains too few children for this node");
}
var {{camel_case($field.Name)}} = ({{$field.Type}})enumerator.Current!;
{{end}}
if (enumerator.MoveNext())
{
throw new System.ArgumentOutOfRangeException(
nameof(children),
"the sequence contains too many children for this node");
}
return this.Update(
{{wrap separated(', ', $node.Fields)}}
{{camel_case($element.Name)}}
Expand Down

0 comments on commit ccfd852

Please sign in to comment.