diff --git a/go/types/expr.go b/go/types/expr.go index c55ce6a1..71b1b34e 100644 --- a/go/types/expr.go +++ b/go/types/expr.go @@ -1126,8 +1126,11 @@ func (check *Checker) exprInternal(x *operand, e ast.Expr, hint Type) exprKind { } default: - check.errorf(e.Pos(), "invalid composite literal type %s", typ) - goto Error + // 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 diff --git a/go/types/testdata/issues.src b/go/types/testdata/issues.src index 58c450f8..417f06c5 100644 --- a/go/types/testdata/issues.src +++ b/go/types/testdata/issues.src @@ -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} +}