diff --git a/src/Draco.Compiler/Internal/Syntax/Formatting/Formatter.cs b/src/Draco.Compiler/Internal/Syntax/Formatting/Formatter.cs index b3217424c..701283a58 100644 --- a/src/Draco.Compiler/Internal/Syntax/Formatting/Formatter.cs +++ b/src/Draco.Compiler/Internal/Syntax/Formatting/Formatter.cs @@ -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)); diff --git a/src/Draco.SourceGeneration/Templates/GreenSyntaxTree.sbncs b/src/Draco.SourceGeneration/Templates/GreenSyntaxTree.sbncs index efb426782..eadb36d11 100644 --- a/src/Draco.SourceGeneration/Templates/GreenSyntaxTree.sbncs +++ b/src/Draco.SourceGeneration/Templates/GreenSyntaxTree.sbncs @@ -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)}}