Skip to content

Commit cd7c3c1

Browse files
authored
Check for at least one input/return type in method (#733)
When generating the FDP for methods, check that there is at least one input/return type, otherwise `TypeList.At(0)` will panic without at least one value.
1 parent 64e6ad0 commit cd7c3c1

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

experimental/fdp/generator.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -574,12 +574,14 @@ func (g *generator) method(m ir.Method, mdp *descriptorpb.MethodDescriptorProto)
574574
*streamField = addr(stream)
575575
}
576576

577-
// Methods only have a single input/output, see [descriptorpb.MethodDescriptorProto].
578-
ast := tys.At(0)
579-
if prefixed := ast.AsPrefixed(); !prefixed.IsZero() {
580-
g.debug.span(prefixed.PrefixToken(), streamTag)
577+
if !ty.IsZero() {
578+
// Methods only have a single input/output, see [descriptorpb.MethodDescriptorProto].
579+
ast := tys.At(0)
580+
if prefixed := ast.AsPrefixed(); !prefixed.IsZero() {
581+
g.debug.span(prefixed.PrefixToken(), streamTag)
582+
}
583+
g.debug.span(ast.RemovePrefixes(), typeTag)
581584
}
582-
g.debug.span(ast.RemovePrefixes(), typeTag)
583585
}
584586

585587
ast := m.AST().AsMethod()

0 commit comments

Comments
 (0)