code review 9703044: go.tools/ssa: print identifer location if not found in ... (issue 9703044)

13 views
Skip to first unread message

g...@golang.org

unread,
May 25, 2013, 12:19:41 PM5/25/13
to adon...@google.com, golan...@googlegroups.com, re...@codereview-hr.appspotmail.com
Reviewers: adonovan,

Message:
Hello adon...@google.com (cc: golan...@googlegroups.com),

I'd like you to review this change to
https://code.google.com/p/go.tools


Description:
go.tools/ssa: print identifer location if not found in TypeInfo

Please review this at https://codereview.appspot.com/9703044/

Affected files:
M ssa/builder.go
M ssa/typeinfo.go


Index: ssa/builder.go
===================================================================
--- a/ssa/builder.go
+++ b/ssa/builder.go
@@ -2471,6 +2471,7 @@
//
func (b *Builder) typecheck(importPath string, files []*ast.File)
(*types.Package, *TypeInfo, error) {
info := &TypeInfo{
+ fset: b.Prog.Files,
types: make(map[ast.Expr]types.Type),
idents: make(map[*ast.Ident]types.Object),
constants: make(map[ast.Expr]*Literal),
Index: ssa/typeinfo.go
===================================================================
--- a/ssa/typeinfo.go
+++ b/ssa/typeinfo.go
@@ -7,11 +7,13 @@
"code.google.com/p/go.tools/go/types"
"fmt"
"go/ast"
+ "go/token"
)

// TypeInfo contains information provided by the type checker about
// the abstract syntax for a single package.
type TypeInfo struct {
+ fset *token.FileSet
types map[ast.Expr]types.Type // inferred types of expressions
constants map[ast.Expr]*Literal // values of constant expressions
idents map[*ast.Ident]types.Object // canonical type objects for named
entities
@@ -51,7 +53,7 @@
if obj, ok := info.idents[id]; ok {
return obj
}
- panic(fmt.Sprintf("no types.Object for ast.Ident %s @ %p", id.Name, id))
+ panic(fmt.Sprintf("no types.Object for ast.Ident %s @ %s", id.Name,
info.fset.Position(id.Pos())))
}

// IsType returns true iff expression e denotes a type.


r...@golang.org

unread,
May 25, 2013, 12:27:46 PM5/25/13
to g...@golang.org, adon...@google.com, golan...@googlegroups.com, re...@codereview-hr.appspotmail.com

g...@golang.org

unread,
May 25, 2013, 1:04:57 PM5/25/13
to g...@golang.org, adon...@google.com, r...@golang.org, golan...@googlegroups.com, re...@codereview-hr.appspotmail.com
*** Submitted as
https://code.google.com/p/go/source/detail?r=a7fc50329a08&repo=tools ***

go.tools/ssa: print identifer location if not found in TypeInfo

R=adonovan, r
CC=golang-dev
https://codereview.appspot.com/9703044


https://codereview.appspot.com/9703044/
Reply all
Reply to author
Forward
0 new messages