]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: remove types.Type.SetBroken
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Tue, 22 Mar 2022 13:43:43 +0000 (20:43 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Wed, 23 Mar 2022 19:31:11 +0000 (19:31 +0000)
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 <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/cmd/compile/internal/typecheck/typecheck.go
src/cmd/compile/internal/types/size.go
src/cmd/compile/internal/types/type.go

index ccf4183435fcd1b4b5601a18cd5219decc695e9b..7b9e35b4440032197c10af828fcd3e84ef1fd52a 100644 (file)
@@ -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
index 3bf3709dcd11df0e52da7141d7c54a525688d889..6a3a1262f314cf26b5848fc1a735e69508084de7 100644 (file)
@@ -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)
        }
 
index 5b652147bbdc74fccb5e061a22e56f95606d135a..5c5ed8a50028e96d22dfa96368508c159d2aacec 100644 (file)
@@ -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) {