-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/compile: internal compiler error using type parameters #48103
Comments
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 |
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: |
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 #48016 (comment), I tried building this with
GOEXPERIMENT=unified
and it seems to work.\cc @danscales @mdempsky
The text was updated successfully, but these errors were encountered: