Add back variable assignment at declaration time

This commit is contained in:
nub31
2025-07-03 19:02:25 +02:00
parent 66d47b9100
commit 50b640b364
6 changed files with 43 additions and 28 deletions

View File

@@ -189,7 +189,12 @@ public static class Binder
private static BoundVariableDeclarationNode BindVariableDeclaration(VariableDeclarationNode statement)
{
_variables[statement.Name] = statement.Type;
return new BoundVariableDeclarationNode(statement.Tokens, statement.Name, statement.Type);
var assignment = Optional<BoundExpressionNode>.Empty();
if (statement.Assignment.HasValue)
{
assignment = BindExpression(statement.Assignment.Value);
}
return new BoundVariableDeclarationNode(statement.Tokens, statement.Name, statement.Type, assignment);
}
private static BoundWhileNode BindWhile(WhileNode statement)