Skip to content

Commit

Permalink
parser/encoding: handle unions
Browse files Browse the repository at this point in the history
  • Loading branch information
eandre committed Jun 8, 2024
1 parent fd5f92c commit 7169178
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
19 changes: 19 additions & 0 deletions parser/encoding/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,25 @@ func GetConcreteType(appDecls []*schema.Decl, originalType *schema.Type, typeArg

return resolveTypeParams(&schema.Type{Typ: &schema.Type_Map{Map: mapType}}, typeArgs), nil

case *schema.Type_Union:
// If there are no type arguments, we've got a concrete type
if len(typeArgs) == 0 {
return originalType, nil
}

types := make([]*schema.Type, len(typ.Union.Types))
for i, t := range typ.Union.Types {
// Deep copy the type
cloned := proto.Clone(t).(*schema.Type)
types[i] = resolveTypeParams(cloned, typeArgs)
}

return &schema.Type{Typ: &schema.Type_Union{
Union: &schema.Union{
Types: types,
},
}}, nil

case *schema.Type_List:
// If there are no type arguments, we've got a concrete type
if len(typeArgs) == 0 {
Expand Down
6 changes: 3 additions & 3 deletions tsparser/src/parser/types/type_resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -758,9 +758,9 @@ impl<'a> Ctx<'a> {
other => other,
},

ast::UnaryOp::Bang
| ast::UnaryOp::Tilde
| ast::UnaryOp::Delete => self.expr(&expr.arg),
ast::UnaryOp::Bang | ast::UnaryOp::Tilde | ast::UnaryOp::Delete => {
self.expr(&expr.arg)
}
},
ast::Expr::Update(expr) => self.expr(&expr.arg),
ast::Expr::Bin(expr) => {
Expand Down

0 comments on commit 7169178

Please sign in to comment.