// complete position information relative to the provided file
// set.
//
-// If the expression contains function literals, their bodies
-// are ignored (i.e., the bodies are not type-checked).
-//
// If pkg == nil, the Universe scope is used and the provided
// position pos is ignored. If pkg != nil, and pos is invalid,
// the package scope is used. Otherwise, pos must belong to the
// level untyped constants will return an untyped type rather then the
// respective context-specific type.
//
-func Eval(fset *token.FileSet, pkg *Package, pos token.Pos, expr string) (TypeAndValue, error) {
+func Eval(fset *token.FileSet, pkg *Package, pos token.Pos, expr string) (_ TypeAndValue, err error) {
// determine scope
var scope *Scope
if pkg == nil {
// evaluate node
var x operand
check.rawExpr(&x, node, nil)
- return TypeAndValue{x.mode, x.typ, x.val}, err
+ check.processDelayed(0) // incl. all functions
+
+ return TypeAndValue{x.mode, x.typ, x.val}, nil
}
package p
/* T => , p.T */
`,
+ `
+ package p
+ import "io"
+ type R = io.Reader
+ func _() {
+ /* interface{R}.Read => , func(interface{io.Reader}, p []byte) (n int, err error) */
+ _ = func() {
+ /* interface{io.Writer}.Write => , func(interface{io.Writer}, p []byte) (n int, err error) */
+ type io interface {} // must not shadow io in line above
+ }
+ type R interface {} // must not shadow R in first line of this function body
+ }
+ `,
}
fset := token.NewFileSet()