// cycle detected
for i, tn := range path {
if t.obj.pkg != check.pkg {
- panic("internal error: type cycle via package-external type")
+ panic("type cycle via package-external type")
}
if tn == t.obj {
check.cycleError(path[i:])
return t.info
}
}
- panic("internal error: cycle start not found")
+ panic("cycle start not found")
}
return t.info
}
case nil:
arg = "<nil>"
case operand:
- panic("internal error: should always pass *operand")
+ panic("got operand instead of *operand")
case *operand:
arg = operandString(a, qf)
case syntax.Pos:
func (check *Checker) report(err *error_) {
if err.empty() {
- panic("internal error: reporting no error")
+ panic("no error to report")
}
check.err(err.pos(), err.msg(check.qualifier), err.soft)
}
return m, f
}
if !acceptMethodTypeParams && ftyp.TParams().Len() > 0 {
- panic("internal error: method with type parameters")
+ panic("method with type parameters")
}
// If the methods have type parameters we don't care whether they
return m, f
}
if !acceptMethodTypeParams && ftyp.TParams().Len() > 0 {
- panic("internal error: method with type parameters")
+ panic("method with type parameters")
}
// If V is a (instantiated) generic type, its methods are still
// The underlying type must not be a *Named.
func NewNamed(obj *TypeName, underlying Type, methods []*Func) *Named {
if _, ok := underlying.(*Named); ok {
- panic("types2.NewNamed: underlying type must not be *Named")
+ panic("underlying type must not be *Named")
}
return (*Checker)(nil).newNamed(obj, nil, underlying, nil, methods)
}
check.later(func() {
switch typ.under().(type) {
case *Named:
- panic("internal error: unexpanded underlying type")
+ panic("unexpanded underlying type")
}
typ.check = nil
})
// SetUnderlying sets the underlying type and marks t as complete.
func (t *Named) SetUnderlying(underlying Type) {
if underlying == nil {
- panic("types2.Named.SetUnderlying: underlying type must not be nil")
+ panic("underlying type must not be nil")
}
if _, ok := underlying.(*Named); ok {
- panic("types2.Named.SetUnderlying: underlying type must not be *Named")
+ panic("underlying type must not be *Named")
}
t.load().underlying = underlying
}
}
if n0.check == nil {
- panic("internal error: Named.check == nil but type is incomplete")
+ panic("Named.check == nil but type is incomplete")
}
// Invariant: after this point n0 as well as any named types in its
// Also, doing so would lead to a race condition (was issue #31749).
// Do this check always, not just in debug mode (it's cheap).
if n.obj.pkg != check.pkg {
- panic("internal error: imported type with unresolved underlying type")
+ panic("imported type with unresolved underlying type")
}
n.underlying = u
}
if variadic {
n := params.Len()
if n == 0 {
- panic("types2.NewSignature: variadic function must have at least one parameter")
+ panic("variadic function must have at least one parameter")
}
if _, ok := params.At(n - 1).typ.(*Slice); !ok {
- panic("types2.NewSignature: variadic parameter must be of unnamed slice type")
+ panic("variadic parameter must be of unnamed slice type")
}
}
return &Signature{recv: recv, params: params, results: results, variadic: variadic}
func (check *Checker) funcBody(decl *declInfo, name string, sig *Signature, body *syntax.BlockStmt, iota constant.Value) {
if check.conf.IgnoreFuncBodies {
- panic("internal error: function body not ignored")
+ panic("function body not ignored")
}
if check.conf.Trace {
// SetConstraint sets the type constraint for t.
func (t *TypeParam) SetConstraint(bound Type) {
if bound == nil {
- panic("types2.TypeParam.SetConstraint: bound must not be nil")
+ panic("nil constraint")
}
t.bound = bound
}
for i, tp := range list {
typ := tp.Type().(*TypeParam)
if typ.index >= 0 {
- panic("internal error: type parameter bound more than once")
+ panic("type parameter bound more than once")
}
typ.index = i
}
func assertSortedMethods(list []*Func) {
if !debug {
- panic("internal error: assertSortedMethods called outside debug mode")
+ panic("assertSortedMethods called outside debug mode")
}
if !sort.IsSorted(byUniqueMethodName(list)) {
- panic("internal error: methods not sorted")
+ panic("methods not sorted")
}
}
// Unions only appear as (syntactic) embedded elements
// in interfaces and syntactically cannot be empty.
if t.NumTerms() == 0 {
- panic("internal error: empty union")
+ panic("empty union")
}
for i, t := range t.terms {
if i > 0 {
case RecvOnly:
s = "<-chan "
default:
- panic("unreachable")
+ unreachable()
}
buf.WriteString(s)
if parens {
// special case:
// append(s, "foo"...) leads to signature func([]byte, string...)
if t := asBasic(typ); t == nil || t.kind != String {
- panic("internal error: string type expected")
+ panic("expected string type")
}
writeType(buf, typ, qf, visited)
buf.WriteString("...")
// disjoint requires non-nil, non-top arguments
if debug {
if x == nil || x.typ == nil || y == nil || y.typ == nil {
- panic("internal error: empty or top union term")
+ panic("empty or top union term")
}
}
if !x.disjoint(y) {
}
}
if scope.Insert(obj) != nil {
- panic("internal error: double declaration")
+ panic("double declaration of predeclared identifier")
}
}