Closed dsnet closed 3 years ago
The relevant snippet that seems to exercise the error:
type typedUnmarshaler struct {
typ reflect.Type
fnc unmarshaler
maySkip bool
}
func UnmarshalFuncV2[T any](fn func(UnmarshalOptions, *Decoder, T) error) *Unmarshalers {
t := reflect.TypeOf((*T)(nil)).Elem()
// checkConvertTo(t, false)
typFnc := typedUnmarshaler{
typ: t,
fnc: func(uo UnmarshalOptions, dec *Decoder, va addressableValue) error {
prevDepth, prevLength := dec.tokens.depthLength()
err := fn(uo, dec, va.Convert(t).Interface().(T))
currDepth, currLength := dec.tokens.depthLength()
if (prevDepth != currDepth || prevLength+1 != currLength) && err == nil {
err = errors.New("must read exactly one JSON value")
}
if err != nil {
if err == SkipFunc {
if prevDepth == currDepth && prevLength == currLength {
return SkipFunc
}
err = errors.New("must not read any JSON tokens when skipping")
}
// TODO: Avoid wrapping semantic, syntactic, or I/O errors.
return &SemanticError{action: "unmarshal", GoType: t, Err: err}
}
return nil
},
maySkip: true,
}
return &Unmarshalers{unmarshalers{fncVals: []typedUnmarshaler{typFnc}}}
}
func init() {
_ = UnmarshalFuncV2(func(UnmarshalOptions, *Decoder, string) error {
return nil
})
}
I'm not sure I understand why the error message implicates ./value.go:315
, when the error occurs whether the init
function in my snippet is present or not.
cc: @danscales
Just a missing type case (for unsafe pointer) in our code that is doing some double-checking related to dictionaries/shapes. Will put the simple fix out shortly.
Change https://golang.org/cl/346669 mentions this issue: cmd/compile: fix missing case for shape double-check function
Thanks @danscales for the fix! I confirmed that it fixes my use case and thus far I've run into no more issues.
This is a follow-up to #48016. I'm hitting another internal compiler error.
Reproduction:
Based on @mdempsky's comment in https://github.com/golang/go/issues/48016#issuecomment-907524160, I tried building this with
GOEXPERIMENT=unified
and it seems to work.\cc @danscales @mdempsky