From db506f9e3eed2f31118643f0dec18cf63759569e Mon Sep 17 00:00:00 2001 From: Mirco De Zorzi Date: Tue, 10 Feb 2026 06:07:57 +0100 Subject: [PATCH 1/3] feat: resolve nested types --- Bond.Parser.Tests/ParserFacadeTests.cs | 20 +++++++++++++ Bond.Parser/Parser/SemanticAnalyzer.cs | 39 ++++++++++++++++++++------ 2 files changed, 51 insertions(+), 8 deletions(-) diff --git a/Bond.Parser.Tests/ParserFacadeTests.cs b/Bond.Parser.Tests/ParserFacadeTests.cs index 7a46048..19204fe 100644 --- a/Bond.Parser.Tests/ParserFacadeTests.cs +++ b/Bond.Parser.Tests/ParserFacadeTests.cs @@ -921,4 +921,24 @@ struct User { } #endregion + + #region Issues + + [Fact] + public async Task SetWithAlias_IsParsed() + { + var input = """ + namespace Test + using guid = string; + struct User { + 0: required map map; + } + """; + + var result = await Parse(input); + + result.Success.Should().BeTrue(); + } + + #endregion } diff --git a/Bond.Parser/Parser/SemanticAnalyzer.cs b/Bond.Parser/Parser/SemanticAnalyzer.cs index f469993..72ceb63 100644 --- a/Bond.Parser/Parser/SemanticAnalyzer.cs +++ b/Bond.Parser/Parser/SemanticAnalyzer.cs @@ -173,24 +173,47 @@ private static void CheckForDuplicates(IEnumerable items, string context, } /// - /// Resolves type aliases to their underlying types + /// Resolves type aliases to their underlying types, including nested container types /// private BondType ResolveAliases(BondType type, Namespace[] namespaces) { - if (type is not BondType.UnresolvedUserType unresolved) + return ResolveAliases(type, namespaces, new HashSet()); + } + + private BondType ResolveAliases(BondType type, Namespace[] namespaces, HashSet visiting) + { + return type switch { - return type; - } + BondType.UnresolvedUserType unresolved => ResolveAliasType(unresolved, namespaces, visiting), + BondType.List list => new BondType.List(ResolveAliases(list.ElementType, namespaces, visiting)), + BondType.Vector vector => new BondType.Vector(ResolveAliases(vector.ElementType, namespaces, visiting)), + BondType.Set set => new BondType.Set(ResolveAliases(set.KeyType, namespaces, visiting)), + BondType.Map map => new BondType.Map( + ResolveAliases(map.KeyType, namespaces, visiting), + ResolveAliases(map.ValueType, namespaces, visiting)), + BondType.Nullable nullable => new BondType.Nullable(ResolveAliases(nullable.ElementType, namespaces, visiting)), + BondType.Maybe maybe => new BondType.Maybe(ResolveAliases(maybe.ElementType, namespaces, visiting)), + BondType.Bonded bonded => new BondType.Bonded(ResolveAliases(bonded.StructType, namespaces, visiting)), + _ => type + }; + } + private BondType ResolveAliasType(BondType.UnresolvedUserType unresolved, Namespace[] namespaces, HashSet visiting) + { var decl = _symbolTable.FindSymbol(unresolved.QualifiedName, namespaces); + if (decl is not AliasDeclaration alias) + { + return unresolved; + } - // Recursively resolve aliases - if (decl is AliasDeclaration alias) + if (!visiting.Add(alias)) { - return ResolveAliases(alias.AliasedType, namespaces); + return unresolved; } - return type; + var resolved = ResolveAliases(alias.AliasedType, namespaces, visiting); + visiting.Remove(alias); + return resolved; } private void ValidateField(Field field, Namespace[] namespaces) From f76399d8e755a2361c823ab82eaddd3324356575 Mon Sep 17 00:00:00 2001 From: Mirco De Zorzi Date: Tue, 10 Feb 2026 06:09:52 +0100 Subject: [PATCH 2/3] dump version --- Bond.Parser.CLI/Bond.Parser.CLI.csproj | 2 +- version | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Bond.Parser.CLI/Bond.Parser.CLI.csproj b/Bond.Parser.CLI/Bond.Parser.CLI.csproj index 19d62f7..9437a6b 100644 --- a/Bond.Parser.CLI/Bond.Parser.CLI.csproj +++ b/Bond.Parser.CLI/Bond.Parser.CLI.csproj @@ -17,7 +17,7 @@ true bbc bbc - 0.2.1 + 0.2.2 Mirco De Zorzi Bond IDL compiler and toolchain Bond.Parser.CLI diff --git a/version b/version index 0c62199..ee1372d 100644 --- a/version +++ b/version @@ -1 +1 @@ -0.2.1 +0.2.2 From b731d4125baa04a1549d4a4d26e50d26d20a8129 Mon Sep 17 00:00:00 2001 From: Mirco De Zorzi Date: Tue, 10 Feb 2026 06:20:17 +0100 Subject: [PATCH 3/3] fix tests --- Bond.Parser.Tests/ParserFacadeTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Bond.Parser.Tests/ParserFacadeTests.cs b/Bond.Parser.Tests/ParserFacadeTests.cs index 19204fe..a636a24 100644 --- a/Bond.Parser.Tests/ParserFacadeTests.cs +++ b/Bond.Parser.Tests/ParserFacadeTests.cs @@ -931,7 +931,7 @@ public async Task SetWithAlias_IsParsed() namespace Test using guid = string; struct User { - 0: required map map; + 0: required map properties; } """;