// Start exit block, find address of result.
s.startBlock(bNext)
- fp := n.Left.Type.Results().Field(0)
- if fp == nil || k != callNormal {
+ res := n.Left.Type.Results()
+ if res.NumFields() == 0 || k != callNormal {
// call has no return value. Continue with the next statement.
return nil
}
+ fp := res.Field(0)
return s.entryNewValue1I(ssa.OpOffPtr, Ptrto(fp.Type), fp.Width, s.sp)
}
func (t *Type) Params() *Type { return *t.ParamsP() }
func (t *Type) Results() *Type { return *t.ResultsP() }
-func (t *Type) Recv() *Field { return t.Recvs().Field(0) }
+// Recv returns the receiver of function type t, if any.
+func (t *Type) Recv() *Field {
+ s := t.Recvs()
+ if s.NumFields() == 0 {
+ return nil
+ }
+ return s.Field(0)
+}
// recvsParamsResults stores the accessor functions for a function Type's
// receiver, parameters, and result parameters, in that order.
}
i--
}
- if i == 0 {
- // To simplify automated rewrites of existing code, if the
- // caller asks for the n'th member of an n-element type,
- // return nil instead of panicking.
- // TODO(mdempsky): Make callers responsible for bounds checking.
- return nil
- }
panic("not enough fields")
}