Fix small bug and add todo

This commit is contained in:
nub31
2025-06-22 20:29:36 +02:00
parent 9f988860f9
commit f579cfdbdf

View File

@@ -7,13 +7,14 @@ using UnaryExpressionNode = Syntax.Parsing.Node.UnaryExpressionNode;
namespace Syntax.Typing;
// TODO: Currently anonymous function does not get a new scope
public static class Binder
{
private static SyntaxTree _syntaxTree = null!;
private static DefinitionTable _definitionTable = null!;
private static NubType? _funcReturnType = null;
private static Dictionary<string, NubType> _variables = new();
private static NubType? _funcReturnType;
public static BoundSyntaxTree Bind(SyntaxTree syntaxTree, DefinitionTable definitionTable)
{
@@ -21,6 +22,7 @@ public static class Binder
_definitionTable = definitionTable;
_variables = [];
_funcReturnType = null;
var definitions = new List<BoundDefinitionNode>();
@@ -50,7 +52,7 @@ public static class Binder
{
throw new NotImplementedException("Diagnostics not implemented");
}
var structFields = new List<BoundStructField>();
foreach (var structField in node.Fields)
@@ -64,7 +66,7 @@ public static class Binder
{
throw new NotImplementedException("Diagnostics not implemented");
}
value = BindExpression(structField.Value.Value, definitionField.Type);
}
@@ -269,7 +271,8 @@ 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)
@@ -308,7 +311,7 @@ public static class Binder
}
var expectedType = funcType.Parameters[i];
parameters.Add(BindExpression(parameter, expectedType));
}
@@ -403,7 +406,7 @@ public static class Binder
{
throw new NotImplementedException("Diagnostics not implemented");
}
var initializers = new Dictionary<string, BoundExpressionNode>();
foreach (var (member, initializer) in expression.Initializers)
@@ -413,7 +416,7 @@ public static class Binder
{
throw new NotImplementedException("Diagnostics not implemented");
}
initializers[member] = BindExpression(initializer, definitionField.Type);
}