diff options
author | Robert Griesemer <gri@golang.org> | 2016-12-16 16:28:30 -0800 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2017-01-10 00:10:11 +0000 |
commit | 3e119404372fd0d47de1458802b68522f593bf36 (patch) | |
tree | 3fef88cfe7315fd65cc271d195ef1f9e3caa8e67 /test/alias2.go | |
parent | e0a05c274aa5a3917c5e53f72537e38bb05c10d6 (diff) | |
download | go-3e119404372fd0d47de1458802b68522f593bf36.tar.gz go-3e119404372fd0d47de1458802b68522f593bf36.zip |
[dev.typealias] cmd/compile: recognize type aliases but complain for now (not yet supported)
Added test file.
For #18130.
Change-Id: Ifcfd7cd1acf9dd6a2f4f3d85979d232bb6b8c6b1
Reviewed-on: https://go-review.googlesource.com/34988
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'test/alias2.go')
-rw-r--r-- | test/alias2.go | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/test/alias2.go b/test/alias2.go new file mode 100644 index 0000000000..25df7c287d --- /dev/null +++ b/test/alias2.go @@ -0,0 +1,58 @@ +// errorcheck + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Test basic restrictions on type aliases. + +// The compiler doesn't implement type aliases yet, +// so for now we get the same error (unimplemented) +// everywhere, OR-ed into the ERROR checks. +// TODO(gri) remove the need for "unimplemented" + +package p + +import ( + "reflect" + . "reflect" +) + +// Valid type alias declarations. + +type _ = int // ERROR "unimplemented" +type _ = struct{} // ERROR "unimplemented" +type _ = reflect.Value // ERROR "unimplemented" +type _ = Value // ERROR "unimplemented" + +type ( + a1 = int // ERROR "unimplemented" + a2 = struct{} // ERROR "unimplemented" + a3 = reflect.Value // ERROR "unimplemented" + a4 = Value // ERROR "unimplemented" +) + +func _() { + type _ = int // ERROR "unimplemented" + type _ = struct{} // ERROR "unimplemented" + type _ = reflect.Value // ERROR "unimplemented" + type _ = Value // ERROR "unimplemented" + + type ( + a1 = int // ERROR "unimplemented" + a2 = struct{} // ERROR "unimplemented" + a3 = reflect.Value // ERROR "unimplemented" + a4 = Value // ERROR "unimplemented" + ) +} + +// Invalid type alias declarations. + +type _ = reflect.ValueOf // ERROR "reflect.ValueOf is not a type|unimplemented" + +type b1 = struct{} // ERROR "unimplemented" +func (b1) m() {} // disabled ERROR "invalid receiver type" + +// TODO(gri) expand +// It appears that type-checking exits after some more severe errors, so we may +// need more test files. |