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/Bond.Parser.Tests/ParserFacadeTests.cs b/Bond.Parser.Tests/ParserFacadeTests.cs
index 7a46048..a636a24 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 properties;
+ }
+ """;
+
+ 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)
diff --git a/version b/version
index 0c62199..ee1372d 100644
--- a/version
+++ b/version
@@ -1 +1 @@
-0.2.1
+0.2.2