go/types: avoid follow-up error if composite literal type is unknown
Fixes #9182. Change-Id: I7090e600e9981131db7f323e7ce6419017e95458 Reviewed-on: https://go-review.googlesource.com/2481 Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
parent
8ab2c33bea
commit
4ad370efaa
|
@ -1126,9 +1126,12 @@ func (check *Checker) exprInternal(x *operand, e ast.Expr, hint Type) exprKind {
|
|||
}
|
||||
|
||||
default:
|
||||
// if utyp is invalid, an error was reported before
|
||||
if utyp != Typ[Invalid] {
|
||||
check.errorf(e.Pos(), "invalid composite literal type %s", typ)
|
||||
goto Error
|
||||
}
|
||||
}
|
||||
|
||||
x.mode = value
|
||||
x.typ = typ
|
||||
|
|
|
@ -35,3 +35,9 @@ func issue8799b(x int, ok bool) {
|
|||
_ = !ok
|
||||
_ = x
|
||||
}
|
||||
|
||||
func issue9182() {
|
||||
type Point C /* ERROR undeclared */ .Point
|
||||
// no error for composite literal based on unknown type
|
||||
_ = Point{x: 1, y: 2}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue