fix: improve handling of untyped complex numbers

This commit is contained in:
Marc Vertes
2019-10-29 18:14:05 +01:00
committed by Traefiker Bot
parent 714253c1e6
commit 3969ab16c4
9 changed files with 156 additions and 49 deletions

View File

@@ -288,6 +288,9 @@ func nodeType(interp *Interpreter, sc *scope, n *node) (*itype, error) {
default:
err = n.cfgErrorf("invalid types %s and %s", t0.Kind(), t1.Kind())
}
if nt0.untyped && nt1.untyped {
t.untyped = true
}
}
case "real", "imag":
if t, err = nodeType(interp, sc, n.child[1]); err != nil {
@@ -300,7 +303,7 @@ func nodeType(interp *Interpreter, sc *scope, n *node) (*itype, error) {
case k == reflect.Complex128:
t = sc.getType("float64")
case t.untyped && isNumber(t.TypeOf()):
t = &itype{cat: valueT, rtype: floatType}
t = &itype{cat: valueT, rtype: floatType, untyped: true}
default:
err = n.cfgErrorf("invalid complex type %s", k)
}