cmd/compile/internal/types2: match compiler error for invalid type alias decl

Fixes #45594.

Change-Id: I2fcc784e6908403dd96b009546e1ac2f53b9f0e8
Reviewed-on: https://go-review.googlesource.com/c/go/+/314776
Trust: Robert Griesemer <gri@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
This commit is contained in:
Robert Griesemer 2021-04-28 18:00:16 -07:00 committed by Dan Scales
parent 42953bc9f5
commit 6afa0ae4e5

View file

@ -602,7 +602,11 @@ func (check *Checker) typeDecl(obj *TypeName, tdecl *syntax.TypeDecl, def *Named
if alias {
// type alias declaration
if !check.allowVersion(obj.pkg, 1, 9) {
check.error(tdecl, "type aliases requires go1.9 or later")
if check.conf.CompilerErrorMessages {
check.error(tdecl, "type aliases only supported as of -lang=go1.9")
} else {
check.error(tdecl, "type aliases requires go1.9 or later")
}
}
obj.typ = Typ[Invalid]