Skip to content

Commit

Permalink
fix sumtype checks
Browse files Browse the repository at this point in the history
  • Loading branch information
matt2e committed May 16, 2024
1 parent 39e599f commit bb9a9f8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
2 changes: 1 addition & 1 deletion backend/controller/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func (c *ConsoleService) GetModules(ctx context.Context, req *connect.Request[pb
Config: c,
})

case *schema.Database, *schema.Enum, *schema.FSM:
case *schema.Database, *schema.Enum, *schema.TypeAlias, *schema.FSM:
}
}

Expand Down
2 changes: 2 additions & 0 deletions backend/controller/ingress/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ func transformAliasedFields(sch *schema.Schema, t schema.Type, obj any, aliaser
}
}
}
case *schema.TypeAlias:
return transformAliasedFields(sch, decl.Type, obj, aliaser)
case *schema.Config, *schema.Database, *schema.FSM, *schema.Secret, *schema.Verb:
return fmt.Errorf("%s: unsupported ref type %T", t.Pos, decl)
}
Expand Down
39 changes: 21 additions & 18 deletions go-runtime/compile/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -1204,7 +1204,7 @@ func visitType(pctx *parseContext, pos token.Pos, tnode types.Type, isExported b
Module: pctx.module.Name,
Name: strcase.ToUpperCamel(named.Obj().Name()),
})
case *schema.Data, *schema.Verb, *schema.Config, *schema.Secret, *schema.Database:
case *schema.Data, *schema.Verb, *schema.Config, *schema.Secret, *schema.Database, *schema.FSM:
}
}
}
Expand Down Expand Up @@ -1494,34 +1494,38 @@ func (p *parseContext) getDeclForTypeName(name string) (enum schema.Decl, ok boo

func (p *parseContext) markAsExported(node schema.Node) {
_ = schema.Visit(node, func(n schema.Node, next func() error) error {
switch n := n.(type) {
case *schema.Enum:
n.Export = true
case *schema.TypeAlias:
n.Export = true
case *schema.Data:
n.Export = true
case *schema.Verb:
n.Export = true
case *schema.Ref:
if n.Module != "" && n.Module != p.module.Name {
break
if decl, ok := n.(schema.Decl); ok {
switch decl := decl.(type) {
case *schema.Enum:
decl.Export = true
case *schema.TypeAlias:
decl.Export = true
case *schema.Data:
decl.Export = true
case *schema.Verb:
decl.Export = true
case *schema.Config, *schema.Secret, *schema.Database, *schema.FSM:
return next()
}
} else if r, ok := n.(*schema.Ref); ok {
if r.Module != "" && r.Module != p.module.Name {
return next()
}
for _, d := range p.module.Decls {
switch d := d.(type) {
case *schema.Enum:
if d.Name != n.Name {
if d.Name != r.Name {
continue
}
case *schema.TypeAlias:
if d.Name != n.Name {
if d.Name != r.Name {
continue
}
case *schema.Data:
if d.Name != n.Name {
if d.Name != r.Name {
continue
}
case *schema.Verb, *schema.Config, *schema.Secret, *schema.Database:
case *schema.Verb, *schema.Config, *schema.Secret, *schema.Database, *schema.FSM:
// does not support implicit exporting
continue
default:
Expand All @@ -1533,7 +1537,6 @@ func (p *parseContext) markAsExported(node schema.Node) {
}
}
}
case *schema.Config, *schema.Secret, *schema.Database, *schema.TypeParameter, *schema.EnumVariant:
}
return next()
})
Expand Down

0 comments on commit bb9a9f8

Please sign in to comment.