// 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 doesn't typecheck due to errors in the shift
// expression checker.
"archive/tar",
"archive/zip",
}
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 {
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