...
This commit is contained in:
@@ -188,13 +188,29 @@ public static class Binder
|
||||
|
||||
private static BoundVariableDeclarationNode BindVariableDeclaration(VariableDeclarationNode statement)
|
||||
{
|
||||
_variables[statement.Name] = statement.Type;
|
||||
NubType? type = null;
|
||||
|
||||
if (statement.ExplicitType.HasValue)
|
||||
{
|
||||
type = statement.ExplicitType.Value;
|
||||
}
|
||||
|
||||
var assignment = Optional<BoundExpressionNode>.Empty();
|
||||
if (statement.Assignment.HasValue)
|
||||
{
|
||||
assignment = BindExpression(statement.Assignment.Value);
|
||||
var boundValue = BindExpression(statement.Assignment.Value, type);
|
||||
assignment = boundValue;
|
||||
type = boundValue.Type;
|
||||
}
|
||||
return new BoundVariableDeclarationNode(statement.Tokens, statement.Name, statement.Type, assignment);
|
||||
|
||||
if (type == null)
|
||||
{
|
||||
throw new NotImplementedException("Diagnostics not implemented");
|
||||
}
|
||||
|
||||
_variables[statement.Name] = type;
|
||||
|
||||
return new BoundVariableDeclarationNode(statement.Tokens, statement.Name, statement.ExplicitType, assignment, type);
|
||||
}
|
||||
|
||||
private static BoundWhileNode BindWhile(WhileNode statement)
|
||||
@@ -254,8 +270,7 @@ public static class Binder
|
||||
|
||||
private static BoundArrayInitializerNode BindArrayInitializer(ArrayInitializerNode expression)
|
||||
{
|
||||
return new BoundArrayInitializerNode(expression.Tokens, new NubArrayType(expression.ElementType), BindExpression(expression.Capacity, NubPrimitiveType.U64),
|
||||
expression.ElementType);
|
||||
return new BoundArrayInitializerNode(expression.Tokens, new NubArrayType(expression.ElementType), BindExpression(expression.Capacity, NubPrimitiveType.U64), expression.ElementType);
|
||||
}
|
||||
|
||||
private static BoundBinaryExpressionNode BindBinaryExpression(BinaryExpressionNode expression)
|
||||
|
||||
Reference in New Issue
Block a user