From 6afa0ae4e54ec049f291050b82c2a770bb3644b1 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Wed, 28 Apr 2021 18:00:16 -0700 Subject: [PATCH] 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 Trust: Dan Scales Run-TryBot: Robert Griesemer TryBot-Result: Go Bot Reviewed-by: Dan Scales --- src/cmd/compile/internal/types2/decl.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cmd/compile/internal/types2/decl.go b/src/cmd/compile/internal/types2/decl.go index 178bebe2eca..4966f198921 100644 --- a/src/cmd/compile/internal/types2/decl.go +++ b/src/cmd/compile/internal/types2/decl.go @@ -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]