interp: fix creation of binary composite types (#1391)

* interp: fix creation of binary composite types

Use direct assignment instead of reflect.Value Set method to
initialize a binary composite type, as for non binary types.
It ensures that a new reflect.Value is stored in the frame
instead of modifying a possibly existing one, which can defeat
the purpose of initializing variables in a body loop.

While there, remove the need to have and use a mutex on types.

Fixes #1381.

* review: rework a bit the test

Co-authored-by: mpl <mathieu.lonjaret@gmail.com>
This commit is contained in:
Marc Vertes
2022-05-05 21:31:10 +02:00
committed by GitHub
parent f74d1ea6d8
commit 2248851d77
3 changed files with 65 additions and 10 deletions

View File

@@ -7,7 +7,6 @@ import (
"reflect"
"strconv"
"strings"
"sync"
"github.com/traefik/yaegi/internal/unsafe2"
)
@@ -110,7 +109,6 @@ type structField struct {
// itype defines the internal representation of types in the interpreter.
type itype struct {
mu *sync.Mutex
cat tcat // Type category
field []structField // Array of struct fields if structT or interfaceT
key *itype // Type of key element if MapT or nil