From: Cuong Manh Le Date: Tue, 22 Mar 2022 13:43:43 +0000 (+0700) Subject: cmd/compile: remove types.Type.SetBroken X-Git-Tag: go1.19beta1~947 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=515135f4c3f9c67d51d6d3d7b8fe82559ac2e9f2;p=gostls13.git cmd/compile: remove types.Type.SetBroken And use base.Fatalf in code that use t.SetBroke(true) instead. Updates #51691 Change-Id: I9f3613379dd82d0dd069cdf7b61cbb281810e2e3 Reviewed-on: https://go-review.googlesource.com/c/go/+/394574 Trust: Cuong Manh Le Reviewed-by: Matthew Dempsky Run-TryBot: Cuong Manh Le TryBot-Result: Gopher Robot --- diff --git a/src/cmd/compile/internal/typecheck/typecheck.go b/src/cmd/compile/internal/typecheck/typecheck.go index ccf4183435..7b9e35b444 100644 --- a/src/cmd/compile/internal/typecheck/typecheck.go +++ b/src/cmd/compile/internal/typecheck/typecheck.go @@ -404,31 +404,16 @@ func typecheck(n ir.Node, top int) (res ir.Node) { // this code a bit, especially the final case. switch { case top&(ctxStmt|ctxExpr) == ctxExpr && !isExpr && n.Op() != ir.OTYPE && !isMulti: - base.Errorf("%v used as value", n) - n.SetDiag(true) - if t != nil { - n.SetType(nil) - } + base.Fatalf("%v used as value", n) case top&ctxType == 0 && n.Op() == ir.OTYPE && t != nil: - base.Errorf("type %v is not an expression", n.Type()) - n.SetDiag(true) + base.Fatalf("type %v is not an expression", n.Type()) case top&(ctxStmt|ctxExpr) == ctxStmt && !isStmt && t != nil: - base.Errorf("%v evaluated but not used", n) - n.SetDiag(true) - n.SetType(nil) + base.Fatalf("%v evaluated but not used", n) case top&(ctxType|ctxExpr) == ctxType && n.Op() != ir.OTYPE && n.Op() != ir.ONONAME && (t != nil || n.Op() == ir.ONAME): - base.Errorf("%v is not a type", n) - if t != nil { - if n.Op() == ir.ONAME { - t.SetBroke(true) - } else { - n.SetType(nil) - } - } - + base.Fatalf("%v is not a type", n) } base.Pos = lno diff --git a/src/cmd/compile/internal/types/size.go b/src/cmd/compile/internal/types/size.go index 3bf3709dcd..6a3a1262f3 100644 --- a/src/cmd/compile/internal/types/size.go +++ b/src/cmd/compile/internal/types/size.go @@ -132,15 +132,7 @@ func expandiface(t *Type) { if AllowsGoVersion(t.Pkg(), 1, 18) { continue } - base.ErrorfAt(m.Pos, "interface contains embedded non-interface, non-union %v", m.Type) - m.SetBroke(true) - t.SetBroke(true) - // Add to fields so that error messages - // include the broken embedded type when - // printing t. - // TODO(mdempsky): Revisit this. - methods = append(methods, m) - continue + base.FatalfAt(m.Pos, "interface contains embedded non-interface, non-union %v", m.Type) } // Embedded interface: duplicate all methods @@ -268,7 +260,6 @@ func CalcSize(t *Type) { } if CalcSizeDisabled { - t.SetBroke(true) base.Fatalf("width not calculated: %v", t) } diff --git a/src/cmd/compile/internal/types/type.go b/src/cmd/compile/internal/types/type.go index 5b652147bb..5c5ed8a500 100644 --- a/src/cmd/compile/internal/types/type.go +++ b/src/cmd/compile/internal/types/type.go @@ -229,7 +229,6 @@ func (t *Type) IsShape() bool { return t.flags&typeIsShape != 0 } func (t *Type) HasShape() bool { return t.flags&typeHasShape != 0 } func (t *Type) SetNotInHeap(b bool) { t.flags.set(typeNotInHeap, b) } -func (t *Type) SetBroke(b bool) { base.Assertf(!b, "SetBroke") } func (t *Type) SetNoalg(b bool) { t.flags.set(typeNoalg, b) } func (t *Type) SetDeferwidth(b bool) { t.flags.set(typeDeferwidth, b) } func (t *Type) SetRecur(b bool) { t.flags.set(typeRecur, b) } @@ -796,7 +795,7 @@ func NewField(pos src.XPos, sym *Sym, typ *Type) *Field { Offset: BADWIDTH, } if typ == nil { - f.SetBroke(true) + base.Fatalf("typ is nil") } return f } @@ -1855,7 +1854,7 @@ func NewInterface(pkg *Pkg, methods []*Field, implicit bool) *Type { } } if anyBroke(methods) { - t.SetBroke(true) + base.Fatalf("type contain broken method: %v", methods) } t.extra.(*Interface).pkg = pkg t.extra.(*Interface).implicit = implicit @@ -1996,7 +1995,7 @@ func NewStruct(pkg *Pkg, fields []*Field) *Type { t := newType(TSTRUCT) t.SetFields(fields) if anyBroke(fields) { - t.SetBroke(true) + base.Fatalf("struct contains broken field: %v", fields) } t.extra.(*Struct).pkg = pkg if fieldsHasTParam(fields) {