interp: fix handling interface in operators

In case of interface values, make sure that the concrete type is preserved during type inference.

Fixes #1466.
This commit is contained in:
Marc Vertes
2022-10-25 14:02:05 +02:00
committed by GitHub
parent 7865c90737
commit 4a8093609f
3 changed files with 30 additions and 5 deletions

View File

@@ -598,7 +598,10 @@ func nodeType2(interp *Interpreter, sc *scope, n *node, seen []*node) (t *itype,
}
if isInterfaceSrc(dt) {
dt.val = t
// Set a new interface type preserving the concrete type (.val field).
t2 := *dt
t2.val = t
dt = &t2
}
t = dt