From f579cfdbdf5f2efe3acbc7c3a2a994dd455d7378 Mon Sep 17 00:00:00 2001 From: nub31 Date: Sun, 22 Jun 2025 20:29:36 +0200 Subject: [PATCH] Fix small bug and add todo --- src/Syntax/Typing/Binder.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Syntax/Typing/Binder.cs b/src/Syntax/Typing/Binder.cs index c11bbdb..a82667b 100644 --- a/src/Syntax/Typing/Binder.cs +++ b/src/Syntax/Typing/Binder.cs @@ -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 _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(); @@ -50,7 +52,7 @@ public static class Binder { throw new NotImplementedException("Diagnostics not implemented"); } - + var structFields = new List(); 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(); 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); }