diff options
author | Russ Cox <rsc@golang.org> | 2009-12-23 13:48:44 -0800 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2009-12-23 13:48:44 -0800 |
commit | c1045db1d891ffe9492d57672d64076b869d6027 (patch) | |
tree | e3bcaebb730a9ca60903b4c2a4582baa1aeddd4d | |
parent | e1033d07b454c60623995bf84076b85f70e77225 (diff) | |
download | go-c1045db1d891ffe9492d57672d64076b869d6027.tar.gz go-c1045db1d891ffe9492d57672d64076b869d6027.zip |
go_spec: use PrimaryExpr as type switch expression
Without this change, the spec parses <-c.(type) as (<-c).(type)
but parses <-c.(int) as <-(c.(int)).
With this change, the former parses as <-(c.(type)).
All three parsers already implement this rule, because
they look for the "type" word during parsing of a standard
type assertion. This change merely brings the
spec in line with the implementations.
http://code.google.com/p/go/source/browse/src/cmd/gc/go.y#801
http://code.google.com/p/go/source/browse/src/pkg/go/parser/parser.go#900
http://gcc.gnu.org/viewcvs/branches/gccgo/gcc/go/parse.cc?revision=155389&view=markup#l2469
Pointed out by Brett Kail on golang-nuts.
R=gri
CC=golang-dev
https://golang.org/cl/182044
-rw-r--r-- | doc/go_spec.html | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/doc/go_spec.html b/doc/go_spec.html index 5aed74e00a..ed740187b9 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -3611,7 +3611,7 @@ in the type assertion. <pre class="ebnf"> TypeSwitchStmt = "switch" [ SimpleStmt ";" ] TypeSwitchGuard "{" { TypeCaseClause } "}" . -TypeSwitchGuard = [ identifier ":=" ] Expression "." "(" "type" ")" . +TypeSwitchGuard = [ identifier ":=" ] PrimaryExpr "." "(" "type" ")" . TypeCaseClause = TypeSwitchCase ":" { Statement ";" } . TypeSwitchCase = "case" TypeList | "default" . TypeList = Type { "," Type } . |