interp: fix use of builtins in type definitions

Make len() and cap() work on pointers. Preserve scope in case of
nested calls of cfg.

Fixes #1285.
This commit is contained in:
Marc Vertes
2021-10-18 10:50:14 +02:00
committed by GitHub
parent aa7f0849e3
commit 229ddfdae1
7 changed files with 66 additions and 17 deletions

View File

@@ -456,7 +456,7 @@ func nodeType2(interp *Interpreter, sc *scope, n *node, seen []*node) (t *itype,
length = int(vInt(sym.rval))
default:
// Size is defined by a numeric constant expression.
if _, err = interp.cfg(c0, sc.pkgID, sc.pkgName); err != nil {
if _, err = interp.cfg(c0, sc, sc.pkgID, sc.pkgName); err != nil {
return nil, err
}
v, ok := c0.rval.Interface().(constant.Value)