Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions go/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ func (ctxt *exprTypeContext) exprType(n ast.Node, expectTuple bool, pkg string)
_, t := ctxt.exprType(expr, false, pkg)
if t.Kind == ast.Typ {
debugp("expected value, got type %v", t)
t = badType
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this actually necessary?

return obj, t

Expand Down Expand Up @@ -310,7 +309,7 @@ func (ctxt *exprTypeContext) exprType(n ast.Node, expectTuple bool, pkg string)
return nil, ctxt.certify(n.Elt, ast.Var, t.Pkg)
case *ast.MapType:
t := ctxt.certify(n.Value, ast.Var, t.Pkg)
if expectTuple {
if expectTuple && t.Kind != ast.Bad {
return nil, ctxt.newType(MultiValue{[]ast.Expr{t.Node.(ast.Expr), predecl("bool")}}, ast.Var, t.Pkg)
}
return nil, t
Expand Down
2 changes: 1 addition & 1 deletion godef.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func main() {
case ast.Expr:
if !*tflag {
// try local declarations only
if obj, typ := types.ExprType(e, types.DefaultImporter, types.FileSet); obj != nil {
if obj, typ := types.ExprType(e, types.DefaultImporter, types.FileSet); obj != nil && typ.Kind != ast.Bad {
done(obj, typ)
}
}
Expand Down