X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=src%2Fgo%2Ftypes%2Ftypexpr.go;h=5bc5a1f3ac72565c0e590f34391ecc87fd62ea74;hb=bea55136b2d50fc514ddfba4380311295975a660;hp=d35c6d1263798854135ad0e014291f91691e1e51;hpb=1b03ec8a25412342ca072c0860bdf046d58e82ac;p=gostls13.git diff --git a/src/go/types/typexpr.go b/src/go/types/typexpr.go index d35c6d1263..5bc5a1f3ac 100644 --- a/src/go/types/typexpr.go +++ b/src/go/types/typexpr.go @@ -95,7 +95,7 @@ func (check *Checker) ident(x *operand, e *ast.Ident, def *TypeName, wantType bo x.mode = constant_ case *TypeName: - if check.isBrokenAlias(obj) { + if !check.conf._EnableAlias && check.isBrokenAlias(obj) { check.errorf(e, InvalidDeclCycle, "invalid use of type alias %s in recursive type (see go.dev/issue/50729)", obj.name) return } @@ -394,7 +394,13 @@ func (check *Checker) typInternal(e0 ast.Expr, def *TypeName) (T Type) { func setDefType(def *TypeName, typ Type) { if def != nil { switch t := def.typ.(type) { - // case *_Alias: + case *_Alias: + // t.fromRHS should always be set, either to an invalid type + // in the beginning, or to typ in certain cyclic declarations. + if t.fromRHS != Typ[Invalid] && t.fromRHS != typ { + panic(sprintf(nil, nil, true, "t.fromRHS = %s, typ = %s\n", t.fromRHS, typ)) + } + t.fromRHS = typ case *Basic: assert(t == Typ[Invalid]) case *Named: