interp: allow early constant evaluation from builtin call

One builtin has been identified to be used for constant definition:
len(), with a constant string argument. Add support for this.

Fixes #1012.
This commit is contained in:
Marc Vertes
2021-01-26 11:12:04 +01:00
committed by GitHub
parent 274eecdf18
commit bd60de5995
5 changed files with 72 additions and 5 deletions

View File

@@ -198,7 +198,7 @@ func nodeType(interp *Interpreter, sc *scope, n *node) (*itype, error) {
if sym.kind != constSym {
return nil, c0.cfgErrorf("non-constant array bound %q", c0.ident)
}
if sym.typ == nil || sym.typ.cat != intT {
if sym.typ == nil || sym.typ.cat != intT || !sym.rval.IsValid() {
t.incomplete = true
break
}