interp: fix type assertion for wrapped empty interface
Although empty interfaces are usually not wrapped, for compatibility with the runtime, we may have to wrap them sometime into `valueInterface` type. It allows to preserve interpreter type metadata for interface values exchanged with the runtime. It is necessary to resolve methods and receivers in the absence of reflect support. During type assertions on empty interfaces, we now handle a possible valueInterface and dereference the original value to pursue the type assertion. In the same change, we have improved the format of some panic messages at runtime to give location of offending source at interpreter level. This change will allow to fix traefik/traefik#9362.
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"go/token"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@@ -76,7 +77,9 @@ func runCheck(t *testing.T, p string) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if res := strings.TrimSpace(stdout.String()); res != wanted {
|
||||
// Remove path in output, to have results independent of location.
|
||||
re := regexp.MustCompile(p + ":")
|
||||
if res := re.ReplaceAllString(strings.TrimSpace(stdout.String()), ""); res != wanted {
|
||||
t.Errorf("\ngot: %q,\nwant: %q", res, wanted)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user