]> Cypherpunks repositories - gostls13.git/commitdiff
go/types: minimal support for alias declarations: don't crash
authorRobert Griesemer <gri@golang.org>
Mon, 3 Oct 2016 20:32:11 +0000 (13:32 -0700)
committerRobert Griesemer <gri@golang.org>
Tue, 4 Oct 2016 22:45:24 +0000 (22:45 +0000)
For #16339

Change-Id: I8927f40e0fd166795f41c784ad92449743f73af5
Reviewed-on: https://go-review.googlesource.com/30213
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/go/types/check_test.go
src/go/types/resolver.go
src/go/types/testdata/aliasdecl.src [new file with mode: 0644]

index 5a3032282fed15a89cdd464849db723012a41b27..d823344066b8e221c5c6e61aa982811da3d1610a 100644 (file)
@@ -72,6 +72,7 @@ var tests = [][]string{
        {"testdata/const1.src"},
        {"testdata/constdecl.src"},
        {"testdata/vardecl.src"},
+       {"testdata/aliasdecl.src"},
        {"testdata/expr0.src"},
        {"testdata/expr1.src"},
        {"testdata/expr2.src"},
index 2b81b4a84bac4042930d9628c24d94a5f53ce416..15722dec8d0bedbc368800c9e093215caf99e045 100644 (file)
@@ -274,6 +274,9 @@ func (check *Checker) collectObjects() {
                                                        check.declare(fileScope, nil, obj, token.NoPos)
                                                }
 
+                                       case *ast.AliasSpec:
+                                               check.errorf(s.Name.Pos(), "cannot handle alias declarations yet")
+
                                        case *ast.ValueSpec:
                                                switch d.Tok {
                                                case token.CONST:
diff --git a/src/go/types/testdata/aliasdecl.src b/src/go/types/testdata/aliasdecl.src
new file mode 100644 (file)
index 0000000..d115351
--- /dev/null
@@ -0,0 +1,10 @@
+// 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.
+
+package aliasdecl
+
+import "math"
+
+const _ = math.Pi
+const c /* ERROR "cannot handle alias declarations yet" */ => math.Pi