interp: improve type assertions

In type assertion at compile time, compare signatures between function types only.

Make `itype.numOut()` return the correct value for Go builtins (this was not strictly necessary due to above fix, but it is correct and improves maintainability).

Fixes #1454.
This commit is contained in:
Marc Vertes
2022-09-12 22:30:08 +02:00
committed by GitHub
parent b8301f10a8
commit 021824930d
4 changed files with 34 additions and 2 deletions

View File

@@ -1249,8 +1249,13 @@ func (t *itype) numOut() int {
if t.rtype.Kind() == reflect.Func {
return t.rtype.NumOut()
}
case builtinT:
switch t.name {
case "append", "cap", "complex", "copy", "imag", "len", "make", "new", "real", "recover":
return 1
}
}
return 1
return 0
}
func (t *itype) out(i int) *itype {