1
0
mirror of https://github.com/golang/go synced 2024-11-12 00:20:22 -07:00

go/types: fix Eval to use correct file set when evaluating an expression

This is https://go-review.googlesource.com/10999 which we could not apply
in x/tools/go/types because we must not rely on 1.5 features in that repo
yet.

Change-Id: I9a57cdb7ad4051df278d1fbed90c736df50f426f
Reviewed-on: https://go-review.googlesource.com/11125
Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
Robert Griesemer 2015-06-15 12:49:45 -07:00
parent d63c42df25
commit 7322ef5d2a

View File

@ -65,11 +65,7 @@ func Eval(fset *token.FileSet, pkg *Package, pos token.Pos, expr string) (tv Typ
}
// parse expressions
// BUG(gri) In case of type-checking errors below, the type checker
// doesn't have the correct file set for expr. The correct
// solution requires a ParseExpr that uses the incoming
// file set fset.
node, err := parser.ParseExpr(expr)
node, err := parser.ParseExprFrom(fset, "eval", expr, 0)
if err != nil {
return TypeAndValue{}, err
}