Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
3e8304b3
Commit
3e8304b3
authored
Dec 26, 2012
by
Robert Griesemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
exp/types: some comment fixes
R=adonovan, bradfitz CC=golang-dev
https://golang.org/cl/7018046
parent
888111e0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
4 deletions
+16
-4
gotype_test.go
src/pkg/exp/gotype/gotype_test.go
+2
-2
expr.go
src/pkg/exp/types/expr.go
+8
-0
parser.go
src/pkg/go/parser/parser.go
+6
-2
No files found.
src/pkg/exp/gotype/gotype_test.go
View file @
3e8304b3
...
...
@@ -52,8 +52,8 @@ var tests = []string{
// directories
// Note: Packages that don't typecheck yet are commented out.
// Unless there is comment next to the commented out packages,
// the package does't typecheck due to errors in the shift
// Unless there is
a
comment next to the commented out packages,
// the package does
n
't typecheck due to errors in the shift
// expression checker.
"archive/tar"
,
"archive/zip"
,
...
...
src/pkg/exp/types/expr.go
View file @
3e8304b3
...
...
@@ -714,6 +714,14 @@ func (check *checker) rawExpr(x *operand, e ast.Expr, hint Type, iota int, cycle
}
case
*
ast
.
CompositeLit
:
// TODO(gri) Known bug: The parser doesn't resolve composite literal keys
// because it cannot know the type of the literal and therefore
// cannot know if a key is a struct field or not. Consequently,
// if a key is an identifier, it is unresolved and thus has no
// ast.Objects associated with it. At the moment, the respective
// error message is not issued because the type-checker doesn't
// resolve the identifier, and because it assumes that the parser
// did the resolution.
typ
:=
hint
openArray
:=
false
if
e
.
Type
!=
nil
{
...
...
src/pkg/go/parser/parser.go
View file @
3e8304b3
...
...
@@ -1189,14 +1189,18 @@ func (p *parser) parseElement(keyOk bool) ast.Expr {
return
p
.
parseLiteralValue
(
nil
)
}
x
:=
p
.
checkExpr
(
p
.
parseExpr
(
keyOk
))
// don't resolve if map key
// The parser cannot resolve a key expression because it does not know
// what the composite literal type is: if we have an array/slice index
// or map key, we want to resolve, but if we have a struct field name
// we cannot. Leave this to type-checking phase.
x
:=
p
.
checkExpr
(
p
.
parseExpr
(
keyOk
))
if
keyOk
{
if
p
.
tok
==
token
.
COLON
{
colon
:=
p
.
pos
p
.
next
()
return
&
ast
.
KeyValueExpr
{
Key
:
x
,
Colon
:
colon
,
Value
:
p
.
parseElement
(
false
)}
}
p
.
resolve
(
x
)
// not a
map
key
p
.
resolve
(
x
)
// not a key
}
return
x
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment