]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile, go/parser: disallow "type T = p.T" - must use "=>"
authorRobert Griesemer <gri@golang.org>
Thu, 27 Oct 2016 18:20:20 +0000 (11:20 -0700)
committerRobert Griesemer <gri@golang.org>
Thu, 27 Oct 2016 19:24:47 +0000 (19:24 +0000)
I had added this originally so we can play with different notations
but it doesn't make sense to keep it around since gofmt will convert
a type alias declaration using "=" into one using "=>" anyhow. More
importantly, the spec doesn't permit it.

Change-Id: Icb010b5a9976aebf877e48b3ce9d7245559ca494
Reviewed-on: https://go-review.googlesource.com/32105
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/gc/bexport.go
src/cmd/compile/internal/syntax/parser.go
src/go/parser/parser.go
src/go/parser/short_test.go
src/go/printer/testdata/declarations.golden
src/go/printer/testdata/declarations.input

index ea0f6d7aaf73bfde92e1214b589a7529d7553614..933fd72fa02fac1ac856a14c99d8f311ed29bf6e 100644 (file)
@@ -11,7 +11,7 @@
 The export data is a serialized description of the graph of exported
 "objects": constants, types, variables, and functions. Aliases may be
 directly reexported, and unaliased types may be indirectly reexported
-(as part of the type of a directly exorted object). More generally,
+(as part of the type of a directly exported object). More generally,
 objects referred to from inlined function bodies can be reexported.
 We need to know which package declares these reexported objects, and
 therefore packages are also part of the export graph.
index d0dec3ab1b6e9165345f0837c063351165211ff7..fcf4f5b692050a1ae4b2afcf109ac8b5a05f685a 100644 (file)
@@ -365,8 +365,7 @@ func (p *parser) typeDecl(group *Group) Decl {
        }
 
        name := p.name()
-       // permit both: type T => p.T and: type T = p.T for now
-       if p.got(_Rarrow) || p.got(_Assign) {
+       if p.got(_Rarrow) {
                return p.aliasDecl(Type, name, group)
        }
 
index 0cff9f005ed1b0f28f5f1b8a7e6f98b86dbf2265..375ae03e86cd13167861062507bcc681b5a7c293 100644 (file)
@@ -2343,8 +2343,7 @@ func (p *parser) parseTypeSpec(doc *ast.CommentGroup, _ token.Token, _ int) ast.
        }
 
        ident := p.parseIdent()
-       // permit both: type T => p.T and: type T = p.T for now
-       if p.tok == token.ALIAS || p.tok == token.ASSIGN {
+       if p.tok == token.ALIAS {
                p.next()
                return p.parseAliasSpec(doc, ast.Typ, ident)
        }
index 0360cea0a6f1bcdddbbef59829a37e94d4b9fb86..514dd4c90cb6a172b0fc41aa67efe225b8b7c0d5 100644 (file)
@@ -47,7 +47,7 @@ var valids = []string{
        `package p; var _ = map[P]int{P{}:0, {}:1}`,
        `package p; var _ = map[*P]int{&P{}:0, {}:1}`,
        `package p; const c => p.C; var x => X; type T => p.T; func F => p.F`,
-       `package p; var (_ int; x => p.X; y => Y); type (t => T; t1 = p.T1)`,
+       `package p; var (_ int; x => p.X; y => Y); type (t => T; t1 => p.T1)`,
 }
 
 func TestValid(t *testing.T) {
index 4d888cc8a495fd9510d8d3ff5a6037076198d821..ff14aba1a79156a693c6ba022c3ee197b825907e 100644 (file)
@@ -1015,8 +1015,6 @@ type c => p.C
 type (
        s       struct{}
        a       => A
-       b       => A
-       c       => foo
        ddd     => p.Foo
 )
 
index c3a76858b7a147df46ea90142a20a9734b06770d..748db3b6b18e72cf101459393ab8d0e5d015bce4 100644 (file)
@@ -1029,8 +1029,6 @@ type c => p.C
 type (
        s struct{}
        a => A
-       b = A
-       c = foo
        ddd => p.Foo
 )