Skip to content
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

Use arshal flags instead of coder flags #100

Merged
merged 1 commit into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions arshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,8 @@ func marshalEncode(out *jsontext.Encoder, in any, mo *jsonopts.Struct) (err erro
marshal, _ = mo.Marshalers.(*Marshalers).lookup(marshal, t)
}
if err := marshal(out, va, mo); err != nil {
xe := export.Encoder(out)
if !xe.Flags.Get(jsonflags.AllowDuplicateNames) {
xe.Tokens.InvalidateDisabledNamespaces()
if !mo.Flags.Get(jsonflags.AllowDuplicateNames) {
export.Encoder(out).Tokens.InvalidateDisabledNamespaces()
}
return err
}
Expand Down Expand Up @@ -461,9 +460,8 @@ func unmarshalDecode(in *jsontext.Decoder, out any, uo *jsonopts.Struct) (err er
unmarshal, _ = uo.Unmarshalers.(*Unmarshalers).lookup(unmarshal, t)
}
if err := unmarshal(in, va, uo); err != nil {
xd := export.Decoder(in)
if !xd.Flags.Get(jsonflags.AllowDuplicateNames) {
xd.Tokens.InvalidateDisabledNamespaces()
if !uo.Flags.Get(jsonflags.AllowDuplicateNames) {
export.Decoder(in).Tokens.InvalidateDisabledNamespaces()
}
return err
}
Expand Down
8 changes: 4 additions & 4 deletions arshal_any.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func marshalObjectAny(enc *jsontext.Encoder, obj map[string]any, mo *jsonopts.St
return enc.WriteToken(jsontext.Null)
}
// Optimize for marshaling an empty map without any preceding whitespace.
if !xe.Flags.Get(jsonflags.AnyWhitespace) && !xe.Tokens.Last.NeedObjectName() {
if !mo.Flags.Get(jsonflags.AnyWhitespace) && !xe.Tokens.Last.NeedObjectName() {
xe.Buf = append(xe.Tokens.MayAppendDelim(xe.Buf, '{'), "{}"...)
xe.Tokens.Last.Increment()
if xe.NeedFlush() {
Expand All @@ -118,7 +118,7 @@ func marshalObjectAny(enc *jsontext.Encoder, obj map[string]any, mo *jsonopts.St
}
// A Go map guarantees that each entry has a unique key
// The only possibility of duplicates is due to invalid UTF-8.
if !xe.Flags.Get(jsonflags.AllowInvalidUTF8) {
if !mo.Flags.Get(jsonflags.AllowInvalidUTF8) {
xe.Tokens.Last.DisableNamespace()
}
if !mo.Flags.Get(jsonflags.Deterministic) || len(obj) <= 1 {
Expand Down Expand Up @@ -168,7 +168,7 @@ func unmarshalObjectAny(dec *jsontext.Decoder, uo *jsonopts.Struct) (map[string]
obj := make(map[string]any)
// A Go map guarantees that each entry has a unique key
// The only possibility of duplicates is due to invalid UTF-8.
if !xd.Flags.Get(jsonflags.AllowInvalidUTF8) {
if !uo.Flags.Get(jsonflags.AllowInvalidUTF8) {
xd.Tokens.Last.DisableNamespace()
}
for dec.PeekKind() != '}' {
Expand Down Expand Up @@ -217,7 +217,7 @@ func marshalArrayAny(enc *jsontext.Encoder, arr []any, mo *jsonopts.Struct) erro
return enc.WriteToken(jsontext.Null)
}
// Optimize for marshaling an empty slice without any preceding whitespace.
if !xe.Flags.Get(jsonflags.AnyWhitespace) && !xe.Tokens.Last.NeedObjectName() {
if !mo.Flags.Get(jsonflags.AnyWhitespace) && !xe.Tokens.Last.NeedObjectName() {
xe.Buf = append(xe.Tokens.MayAppendDelim(xe.Buf, '['), "[]"...)
xe.Tokens.Last.Increment()
if xe.NeedFlush() {
Expand Down
44 changes: 22 additions & 22 deletions arshal_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func makeBoolArshaler(t reflect.Type) *arshaler {
}

// Optimize for marshaling without preceding whitespace.
if optimizeCommon && !xe.Flags.Get(jsonflags.AnyWhitespace) && !mo.Flags.Get(jsonflags.StringifyBoolsAndStrings) && !xe.Tokens.Last.NeedObjectName() {
if optimizeCommon && !mo.Flags.Get(jsonflags.AnyWhitespace|jsonflags.StringifyBoolsAndStrings) && !xe.Tokens.Last.NeedObjectName() {
xe.Buf = strconv.AppendBool(xe.Tokens.MayAppendDelim(xe.Buf, 't'), va.Bool())
xe.Tokens.Last.Increment()
if xe.NeedFlush() {
Expand Down Expand Up @@ -200,7 +200,7 @@ func makeStringArshaler(t reflect.Type) *arshaler {

// Optimize for marshaling without preceding whitespace or string escaping.
s := va.String()
if optimizeCommon && !xe.Flags.Get(jsonflags.AnyWhitespace) && !mo.Flags.Get(jsonflags.StringifyBoolsAndStrings) && !xe.Tokens.Last.NeedObjectName() && !jsonwire.NeedEscape(s) {
if optimizeCommon && !mo.Flags.Get(jsonflags.AnyWhitespace|jsonflags.StringifyBoolsAndStrings) && !xe.Tokens.Last.NeedObjectName() && !jsonwire.NeedEscape(s) {
b := xe.Buf
b = xe.Tokens.MayAppendDelim(b, '"')
b = append(b, '"')
Expand Down Expand Up @@ -446,7 +446,7 @@ func makeIntArshaler(t reflect.Type) *arshaler {
}

// Optimize for marshaling without preceding whitespace or string escaping.
if optimizeCommon && !xe.Flags.Get(jsonflags.AnyWhitespace) && !mo.Flags.Get(jsonflags.StringifyNumbers) && !xe.Tokens.Last.NeedObjectName() {
if optimizeCommon && !mo.Flags.Get(jsonflags.AnyWhitespace|jsonflags.StringifyNumbers) && !xe.Tokens.Last.NeedObjectName() {
xe.Buf = strconv.AppendInt(xe.Tokens.MayAppendDelim(xe.Buf, '0'), va.Int(), 10)
xe.Tokens.Last.Increment()
if xe.NeedFlush() {
Expand Down Expand Up @@ -533,7 +533,7 @@ func makeUintArshaler(t reflect.Type) *arshaler {
}

// Optimize for marshaling without preceding whitespace or string escaping.
if optimizeCommon && !xe.Flags.Get(jsonflags.AnyWhitespace) && !mo.Flags.Get(jsonflags.StringifyNumbers) && !xe.Tokens.Last.NeedObjectName() {
if optimizeCommon && !mo.Flags.Get(jsonflags.AnyWhitespace|jsonflags.StringifyNumbers) && !xe.Tokens.Last.NeedObjectName() {
xe.Buf = strconv.AppendUint(xe.Tokens.MayAppendDelim(xe.Buf, '0'), va.Uint(), 10)
xe.Tokens.Last.Increment()
if xe.NeedFlush() {
Expand Down Expand Up @@ -625,7 +625,7 @@ func makeFloatArshaler(t reflect.Type) *arshaler {
}

// Optimize for marshaling without preceding whitespace or string escaping.
if optimizeCommon && !xe.Flags.Get(jsonflags.AnyWhitespace) && !mo.Flags.Get(jsonflags.StringifyNumbers) && !xe.Tokens.Last.NeedObjectName() {
if optimizeCommon && !mo.Flags.Get(jsonflags.AnyWhitespace|jsonflags.StringifyNumbers) && !xe.Tokens.Last.NeedObjectName() {
xe.Buf = jsonwire.AppendFloat(xe.Tokens.MayAppendDelim(xe.Buf, '0'), fv, bits)
xe.Tokens.Last.Increment()
if xe.NeedFlush() {
Expand Down Expand Up @@ -755,7 +755,7 @@ func makeMapArshaler(t reflect.Type) *arshaler {
return enc.WriteToken(jsontext.Null)
}
// Optimize for marshaling an empty map without any preceding whitespace.
if optimizeCommon && !xe.Flags.Get(jsonflags.AnyWhitespace) && !xe.Tokens.Last.NeedObjectName() {
if optimizeCommon && !mo.Flags.Get(jsonflags.AnyWhitespace) && !xe.Tokens.Last.NeedObjectName() {
xe.Buf = append(xe.Tokens.MayAppendDelim(xe.Buf, '{'), "{}"...)
xe.Tokens.Last.Increment()
if xe.NeedFlush() {
Expand Down Expand Up @@ -785,7 +785,7 @@ func makeMapArshaler(t reflect.Type) *arshaler {
// A Go map guarantees that each entry has a unique key.
// As such, disable the expensive duplicate name check if we know
// that every Go key will serialize as a unique JSON string.
if !nonDefaultKey && mapKeyWithUniqueRepresentation(k.Kind(), xe.Flags.Get(jsonflags.AllowInvalidUTF8)) {
if !nonDefaultKey && mapKeyWithUniqueRepresentation(k.Kind(), mo.Flags.Get(jsonflags.AllowInvalidUTF8)) {
xe.Tokens.Last.DisableNamespace()
}

Expand Down Expand Up @@ -913,7 +913,7 @@ func makeMapArshaler(t reflect.Type) *arshaler {
// will be rejected as duplicates since they semantically refer
// to the same Go value. This is an unusual interaction
// between syntax and semantics, but is more correct.
if !nonDefaultKey && mapKeyWithUniqueRepresentation(k.Kind(), xd.Flags.Get(jsonflags.AllowInvalidUTF8)) {
if !nonDefaultKey && mapKeyWithUniqueRepresentation(k.Kind(), uo.Flags.Get(jsonflags.AllowInvalidUTF8)) {
xd.Tokens.Last.DisableNamespace()
}

Expand All @@ -922,7 +922,7 @@ func makeMapArshaler(t reflect.Type) *arshaler {
// since existing presence alone is insufficient to indicate
// whether the input had a duplicate name.
var seen reflect.Value
if !xd.Flags.Get(jsonflags.AllowDuplicateNames) && va.Len() > 0 {
if !uo.Flags.Get(jsonflags.AllowDuplicateNames) && va.Len() > 0 {
seen = reflect.MakeMap(reflect.MapOf(k.Type(), emptyStructType))
}

Expand All @@ -941,7 +941,7 @@ func makeMapArshaler(t reflect.Type) *arshaler {
}

if v2 := va.MapIndex(k.Value); v2.IsValid() {
if !xd.Flags.Get(jsonflags.AllowDuplicateNames) && (!seen.IsValid() || seen.MapIndex(k.Value).IsValid()) {
if !uo.Flags.Get(jsonflags.AllowDuplicateNames) && (!seen.IsValid() || seen.MapIndex(k.Value).IsValid()) {
// TODO: Unread the object name.
name := xd.PreviousTokenOrValue()
return newDuplicateNameError(dec.StackPointer(), nil, dec.InputOffset()-len64(name))
Expand Down Expand Up @@ -1078,20 +1078,20 @@ func makeStructArshaler(t reflect.Type) *arshaler {
b := xe.Buf
if xe.Tokens.Last.Length() > 0 {
b = append(b, ',')
if xe.Flags.Get(jsonflags.SpaceAfterComma) {
if mo.Flags.Get(jsonflags.SpaceAfterComma) {
b = append(b, ' ')
}
}
if xe.Flags.Get(jsonflags.Multiline) {
if mo.Flags.Get(jsonflags.Multiline) {
b = xe.AppendIndent(b, xe.Tokens.NeedIndent('"'))
}

// Append the token to the output and to the state machine.
n0 := len(b) // offset before calling AppendQuote
if !xe.Flags.Get(jsonflags.EscapeForHTML | jsonflags.EscapeForJS | jsonflags.EscapeInvalidUTF8) {
if !mo.Flags.Get(jsonflags.EscapeForHTML | jsonflags.EscapeForJS | jsonflags.EscapeInvalidUTF8) {
b = append(b, f.quotedName...)
} else {
b, _ = jsonwire.AppendQuote(b, f.name, &xe.Flags)
b, _ = jsonwire.AppendQuote(b, f.name, &mo.Flags)
}
xe.Buf = b
xe.Names.ReplaceLastQuotedOffset(n0)
Expand Down Expand Up @@ -1136,14 +1136,14 @@ func makeStructArshaler(t reflect.Type) *arshaler {
// Remember the previous written object member.
// The set of seen fields only needs to be updated to detect
// duplicate names with those from the inlined fallback.
if !xe.Flags.Get(jsonflags.AllowDuplicateNames) && fields.inlinedFallback != nil {
if !mo.Flags.Get(jsonflags.AllowDuplicateNames) && fields.inlinedFallback != nil {
seenIdxs.insert(uint(f.id))
}
prevIdx = f.id
}
if fields.inlinedFallback != nil && !(mo.Flags.Get(jsonflags.DiscardUnknownMembers) && fields.inlinedFallback.unknown) {
var insertUnquotedName func([]byte) bool
if !xe.Flags.Get(jsonflags.AllowDuplicateNames) {
if !mo.Flags.Get(jsonflags.AllowDuplicateNames) {
insertUnquotedName = func(name []byte) bool {
// Check that the name from inlined fallback does not match
// one of the previously marshaled names from known fields.
Expand Down Expand Up @@ -1215,7 +1215,7 @@ func makeStructArshaler(t reflect.Type) *arshaler {
if uo.Flags.Get(jsonflags.RejectUnknownMembers) && (fields.inlinedFallback == nil || fields.inlinedFallback.unknown) {
return newUnmarshalErrorAfter(dec, t, ErrUnknownName)
}
if !xd.Flags.Get(jsonflags.AllowDuplicateNames) && !xd.Namespaces.Last().InsertUnquoted(name) {
if !uo.Flags.Get(jsonflags.AllowDuplicateNames) && !xd.Namespaces.Last().InsertUnquoted(name) {
// TODO: Unread the object name.
return newDuplicateNameError(dec.StackPointer(), nil, dec.InputOffset()-len64(val))
}
Expand All @@ -1234,7 +1234,7 @@ func makeStructArshaler(t reflect.Type) *arshaler {
continue
}
}
if !xd.Flags.Get(jsonflags.AllowDuplicateNames) && !seenIdxs.insert(uint(f.id)) {
if !uo.Flags.Get(jsonflags.AllowDuplicateNames) && !seenIdxs.insert(uint(f.id)) {
// TODO: Unread the object name.
return newDuplicateNameError(dec.StackPointer(), nil, dec.InputOffset()-len64(val))
}
Expand Down Expand Up @@ -1383,7 +1383,7 @@ func makeSliceArshaler(t reflect.Type) *arshaler {
return enc.WriteToken(jsontext.Null)
}
// Optimize for marshaling an empty slice without any preceding whitespace.
if optimizeCommon && !xe.Flags.Get(jsonflags.AnyWhitespace) && !xe.Tokens.Last.NeedObjectName() {
if optimizeCommon && !mo.Flags.Get(jsonflags.AnyWhitespace) && !xe.Tokens.Last.NeedObjectName() {
xe.Buf = append(xe.Tokens.MayAppendDelim(xe.Buf, '['), "[]"...)
xe.Tokens.Last.Increment()
if xe.NeedFlush() {
Expand Down Expand Up @@ -1624,7 +1624,7 @@ func makePointerArshaler(t reflect.Type) *arshaler {
return err
}
if uo.Flags.Get(jsonflags.StringifyWithLegacySemantics) &&
(uo.Flags.Get(jsonflags.StringifyNumbers) || uo.Flags.Get(jsonflags.StringifyBoolsAndStrings)) {
uo.Flags.Get(jsonflags.StringifyNumbers|jsonflags.StringifyBoolsAndStrings) {
// A JSON null quoted within a JSON string should take effect
// within the pointer value, rather than the indirect value.
//
Expand Down Expand Up @@ -1664,7 +1664,7 @@ func makeInterfaceArshaler(t reflect.Type) *arshaler {
}
// Optimize for the any type if there are no special options.
if optimizeCommon &&
t == anyType && !mo.Flags.Get(jsonflags.StringifyNumbers) && !mo.Flags.Get(jsonflags.StringifyBoolsAndStrings) && mo.Format == "" &&
t == anyType && !mo.Flags.Get(jsonflags.StringifyNumbers|jsonflags.StringifyBoolsAndStrings) && mo.Format == "" &&
(mo.Marshalers == nil || !mo.Marshalers.(*Marshalers).fromAny) {
return marshalValueAny(enc, va.Elem().Interface(), mo)
}
Expand Down Expand Up @@ -1709,7 +1709,7 @@ func makeInterfaceArshaler(t reflect.Type) *arshaler {
// Duplicate name check must be enforced since unmarshalValueAny
// does not implement merge semantics.
if optimizeCommon &&
t == anyType && !xd.Flags.Get(jsonflags.AllowDuplicateNames) && uo.Format == "" &&
t == anyType && !uo.Flags.Get(jsonflags.AllowDuplicateNames) && uo.Format == "" &&
(uo.Unmarshalers == nil || !uo.Unmarshalers.(*Unmarshalers).fromAny) {
v, err := unmarshalValueAny(dec, uo)
// We must check for nil interface values up front.
Expand Down
8 changes: 4 additions & 4 deletions arshal_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func MarshalFuncV1[T any](fn func(T) ([]byte, error)) *Marshalers {
val, err := fn(va.castTo(t).Interface().(T))
if err != nil {
err = wrapSkipFunc(err, "marshal function of type func(T) ([]byte, error)")
if export.Encoder(enc).Flags.Get(jsonflags.ReportLegacyErrorValues) {
if mo.Flags.Get(jsonflags.ReportLegacyErrorValues) {
return internal.NewMarshalerError(va.Addr().Interface(), err, "MarshalFuncV1") // unlike unmarshal, always wrapped
}
err = newMarshalErrorBefore(enc, t, err)
Expand Down Expand Up @@ -230,7 +230,7 @@ func MarshalFuncV2[T any](fn func(*jsontext.Encoder, T, Options) error) *Marshal
}
err = errSkipMutation
}
if xe.Flags.Get(jsonflags.ReportLegacyErrorValues) {
if mo.Flags.Get(jsonflags.ReportLegacyErrorValues) {
return internal.NewMarshalerError(va.Addr().Interface(), err, "MarshalFuncV2") // unlike unmarshal, always wrapped
}
if !export.IsIOError(err) {
Expand Down Expand Up @@ -267,7 +267,7 @@ func UnmarshalFuncV1[T any](fn func([]byte, T) error) *Unmarshalers {
err = fn(val, va.castTo(t).Interface().(T))
if err != nil {
err = wrapSkipFunc(err, "unmarshal function of type func([]byte, T) error")
if export.Decoder(dec).Flags.Get(jsonflags.ReportLegacyErrorValues) {
if uo.Flags.Get(jsonflags.ReportLegacyErrorValues) {
return err // unlike marshal, never wrapped
}
err = newUnmarshalErrorAfter(dec, t, err)
Expand Down Expand Up @@ -312,7 +312,7 @@ func UnmarshalFuncV2[T any](fn func(*jsontext.Decoder, T, Options) error) *Unmar
}
err = errSkipMutation
}
if export.Decoder(dec).Flags.Get(jsonflags.ReportLegacyErrorValues) {
if uo.Flags.Get(jsonflags.ReportLegacyErrorValues) {
return err // unlike marshal, never wrapped
}
if !isSyntacticError(err) && !export.IsIOError(err) {
Expand Down
3 changes: 1 addition & 2 deletions arshal_inlined.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ func marshalInlinedFallbackAll(enc *jsontext.Encoder, va addressableValue, mo *j
mk := newAddressableValue(m.Type().Key())
mv := newAddressableValue(m.Type().Elem())
marshalKey := func(mk addressableValue) error {
xe := export.Encoder(enc)
b, err := jsonwire.AppendQuote(enc.UnusedBuffer(), mk.String(), &xe.Flags)
b, err := jsonwire.AppendQuote(enc.UnusedBuffer(), mk.String(), &mo.Flags)
if err != nil {
return newMarshalErrorBefore(enc, m.Type().Key(), err)
}
Expand Down
14 changes: 7 additions & 7 deletions arshal_methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func makeMethodArshaler(fncs *arshaler, t reflect.Type) *arshaler {
return append(b, b2...), err
}); err != nil {
err = wrapSkipFunc(err, "marshal method")
if export.Encoder(enc).Flags.Get(jsonflags.ReportLegacyErrorValues) {
if mo.Flags.Get(jsonflags.ReportLegacyErrorValues) {
return internal.NewMarshalerError(va.Addr().Interface(), err, "MarshalText") // unlike unmarshal, always wrapped
}
if !isSemanticError(err) && !export.IsIOError(err) {
Expand Down Expand Up @@ -155,7 +155,7 @@ func makeMethodArshaler(fncs *arshaler, t reflect.Type) *arshaler {
appender := va.Addr().Interface().(encodingTextAppender)
if err := export.Encoder(enc).AppendRaw('"', false, appender.AppendText); err != nil {
err = wrapSkipFunc(err, "append method")
if export.Encoder(enc).Flags.Get(jsonflags.ReportLegacyErrorValues) {
if mo.Flags.Get(jsonflags.ReportLegacyErrorValues) {
return internal.NewMarshalerError(va.Addr().Interface(), err, "AppendText") // unlike unmarshal, always wrapped
}
if !isSemanticError(err) && !export.IsIOError(err) {
Expand All @@ -174,7 +174,7 @@ func makeMethodArshaler(fncs *arshaler, t reflect.Type) *arshaler {
val, err := marshaler.MarshalJSON()
if err != nil {
err = wrapSkipFunc(err, "marshal method")
if export.Encoder(enc).Flags.Get(jsonflags.ReportLegacyErrorValues) {
if mo.Flags.Get(jsonflags.ReportLegacyErrorValues) {
return internal.NewMarshalerError(va.Addr().Interface(), err, "MarshalJSON") // unlike unmarshal, always wrapped
}
err = newMarshalErrorBefore(enc, t, err)
Expand Down Expand Up @@ -204,7 +204,7 @@ func makeMethodArshaler(fncs *arshaler, t reflect.Type) *arshaler {
}
if err != nil {
err = wrapSkipFunc(err, "marshal method")
if xe.Flags.Get(jsonflags.ReportLegacyErrorValues) {
if mo.Flags.Get(jsonflags.ReportLegacyErrorValues) {
return internal.NewMarshalerError(va.Addr().Interface(), err, "MarshalJSONV2") // unlike unmarshal, always wrapped
}
if !export.IsIOError(err) {
Expand Down Expand Up @@ -238,7 +238,7 @@ func makeMethodArshaler(fncs *arshaler, t reflect.Type) *arshaler {
unmarshaler := va.Addr().Interface().(encoding.TextUnmarshaler)
if err := unmarshaler.UnmarshalText(s); err != nil {
err = wrapSkipFunc(err, "unmarshal method")
if export.Decoder(dec).Flags.Get(jsonflags.ReportLegacyErrorValues) {
if uo.Flags.Get(jsonflags.ReportLegacyErrorValues) {
return err // unlike marshal, never wrapped
}
if !isSemanticError(err) && !isSyntacticError(err) && !export.IsIOError(err) {
Expand All @@ -260,7 +260,7 @@ func makeMethodArshaler(fncs *arshaler, t reflect.Type) *arshaler {
unmarshaler := va.Addr().Interface().(UnmarshalerV1)
if err := unmarshaler.UnmarshalJSON(val); err != nil {
err = wrapSkipFunc(err, "unmarshal method")
if export.Decoder(dec).Flags.Get(jsonflags.ReportLegacyErrorValues) {
if uo.Flags.Get(jsonflags.ReportLegacyErrorValues) {
return err // unlike marshal, never wrapped
}
err = newUnmarshalErrorAfter(dec, t, err)
Expand All @@ -284,7 +284,7 @@ func makeMethodArshaler(fncs *arshaler, t reflect.Type) *arshaler {
}
if err != nil {
err = wrapSkipFunc(err, "unmarshal method")
if xd.Flags.Get(jsonflags.ReportLegacyErrorValues) {
if uo.Flags.Get(jsonflags.ReportLegacyErrorValues) {
return err // unlike marshal, never wrapped
}
if !isSyntacticError(err) && !export.IsIOError(err) {
Expand Down
Loading