Skip to content

Commit a599706

Browse files
committed
[dev.go2go] go/types: don't crash instantiating defined types that are not fully set up
Addresses crash #16 of #39634. Updates #39634. Change-Id: I33063d6e2176586f097d2d1391f490f1775a2202 Reviewed-on: https://go-review.googlesource.com/c/go/+/241122 Reviewed-by: Robert Griesemer <[email protected]>
1 parent 005397e commit a599706

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/go/types/fixedbugs/issue39634.go2

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ type foo8(type A) interface { type A }
2727
func bar8(type A foo8(A))(a A) {}
2828
func main8() {}
2929

30+
// crash 16
31+
type Foo16(type T) r16 /* ERROR not a type */
32+
func r16(type T)() Foo16((Foo16(T)))
33+
3034
// crash 17
3135
type Y17 interface{ c() }
3236
type Z17 interface {

src/go/types/subst.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,6 @@ func (subst *subster) typ(typ Type) Type {
337337
}
338338
}
339339

340-
assert(t.underlying != nil)
341-
342340
if t.tparams == nil {
343341
dump(">>> %s is not parameterized", t)
344342
return t // type is not parameterized
@@ -399,7 +397,7 @@ func (subst *subster) typ(typ Type) Type {
399397

400398
// do the substitution
401399
dump(">>> subst %s with %s (new: %s)", t.underlying, subst.smap, new_targs)
402-
named.underlying = subst.typ(t.underlying)
400+
named.underlying = subst.typOrNil(t.underlying)
403401
named.orig = named.underlying // for cycle detection (Checker.validType)
404402

405403
return named

0 commit comments

Comments
 (0)