You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
line 394:
funcmakeValue(t reflect.Type) (reflect.Value, error) {
switcht.Kind() {
casereflect.Chan:
returnreflect.MakeChan(t, 0), nilcasereflect.Func:
returnreflect.MakeFunc(t, nil), nilcasereflect.Map:
// note creating slice as work around to create map// just doing MakeMap can give incorrect type for defined typesvalue:=reflect.MakeSlice(reflect.SliceOf(t), 0, 1)
value=reflect.Append(value, reflect.MakeMap(reflect.MapOf(t.Key(), t.Elem())))
returnvalue.Index(0), nilcasereflect.Ptr:
ptrV:=reflect.New(t.Elem())
v, err:=makeValue(t.Elem())
iferr!=nil {
returnnilValue, err
}
ptrV.Elem().Set(v)
returnptrV, nilcasereflect.Slice:
returnreflect.MakeSlice(t, 0, 0), nilcasereflect.Struct:
structV:=reflect.New(t).Elem()
fori:=0; i<structV.NumField(); i++ {
// here Pointer will be zero value, but other type is notifstructV.Field(i).Kind() ==reflect.Ptr {
continue
}
v, err:=makeValue(structV.Field(i).Type())
iferr!=nil {
returnnilValue, err
}
ifstructV.Field(i).CanSet() {
structV.Field(i).Set(v)
}
}
returnstructV, nil// only this code is ok// return reflect.New(t).Elem(), nil
}
returnreflect.New(t).Elem(), nil
}
The text was updated successfully, but these errors were encountered:
For-ACGN
added a commit
to For-ACGN/anko
that referenced
this issue
Dec 31, 2020
test code:
output:
file anko/vm/vm.go:
The text was updated successfully, but these errors were encountered: