diff --git a/backend/schema/protobuf_dec.go b/backend/schema/protobuf_dec.go index bf58d081f6..9e1bc31d66 100644 --- a/backend/schema/protobuf_dec.go +++ b/backend/schema/protobuf_dec.go @@ -56,8 +56,10 @@ func typeToSchema(s *schemapb.Type) Type { return mapToSchema(s.Map) case *schemapb.Type_Optional: return &Optional{Pos: posFromProto(s.Optional.Pos), Type: typeToSchema(s.Optional.Type)} + case *schemapb.Type_Unit: + return &Unit{Pos: posFromProto(s.Unit.Pos)} } - panic("unreachable") + panic(fmt.Sprintf("unhandled type: %T", s.Value)) } func metadataListToSchema(s []*schemapb.Metadata) []Metadata { diff --git a/backend/schema/protobuf_enc.go b/backend/schema/protobuf_enc.go index 702f63ea9e..d62ee06bcc 100644 --- a/backend/schema/protobuf_enc.go +++ b/backend/schema/protobuf_enc.go @@ -114,5 +114,5 @@ func typeToProto(t Type) *schemapb.Type { case *Optional: return &schemapb.Type{Value: &schemapb.Type_Optional{Optional: t.ToProto().(*schemapb.Optional)}} } - panic("unreachable") + panic(fmt.Sprintf("unhandled type: %T", t)) } diff --git a/go-runtime/compile/schema.go b/go-runtime/compile/schema.go index 3c17d9de15..5dd6fc4bbc 100644 --- a/go-runtime/compile/schema.go +++ b/go-runtime/compile/schema.go @@ -259,7 +259,7 @@ func visitFuncDecl(pctx *parseContext, node *ast.FuncDecl) (verb *schema.Verb, e } var req schema.Type if reqt != nil { - req, err = parseStruct(pctx, node, params.At(1).Type()) + req, err = parseType(pctx, node, params.At(1).Type()) if err != nil { return nil, err } @@ -268,7 +268,7 @@ func visitFuncDecl(pctx *parseContext, node *ast.FuncDecl) (verb *schema.Verb, e } var resp schema.Type if respt != nil { - resp, err = parseStruct(pctx, node, results.At(0).Type()) + resp, err = parseType(pctx, node, results.At(0).Type()) if err != nil { return nil, err } @@ -405,6 +405,9 @@ func parseType(pctx *parseContext, node ast.Node, tnode types.Type) (schema.Type case "time.Time": return &schema.Time{Pos: goPosToSchemaPos(node.Pos())}, nil + case "github.com/TBD54566975/ftl/go-runtime/sdk.Unit": + return &schema.Unit{Pos: goPosToSchemaPos(node.Pos())}, nil + case "github.com/TBD54566975/ftl/go-runtime/sdk.Option": underlying, err := parseType(pctx, node, named.TypeArgs().At(0)) if err != nil {