func (check *Checker) varDecl(obj *Var, lhs []*Var, typ, init ast.Expr) {
assert(obj.typ == nil)
- // If we have undefined variable types due to errors,
- // mark variables as used to avoid follow-on errors.
- // Matches compiler behavior.
- defer func() {
- if obj.typ == Typ[Invalid] {
- obj.used = true
- }
- for _, lhs := range lhs {
- if lhs.typ == Typ[Invalid] {
- lhs.used = true
- }
- }
- }()
-
// determine type, if any
if typ != nil {
obj.typ = check.varType(typ)
if alias {
// type alias declaration
+ if !check.allowVersion(obj.pkg, 1, 9) {
+ check.errorf(atPos(tdecl.Assign), _BadDecl, "type aliases requires go1.9 or later")
+ }
obj.typ = Typ[Invalid]
obj.typ = check.anyType(tdecl.Type)