internal/impl: fix legacy UnmarshalJSONEnum

The conditional was accidentally inverted.
This function provides dubious support for encoding/json.

Change-Id: Ib4131a229afa14d9aef1ad31fec51f4dac417a3b
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/210638
Reviewed-by: Damien Neil <dneil@google.com>
This commit is contained in:
Joe Tsai 2019-12-09 21:18:02 -08:00 committed by Joe Tsai
parent 4663ebc852
commit 62d204ccc3

View File

@ -45,7 +45,7 @@ func (Export) UnmarshalJSONEnum(ed pref.EnumDescriptor, b []byte) (pref.EnumNumb
return 0, errors.New("invalid input for enum %v: %s", ed.FullName(), b)
}
ev := ed.Values().ByName(name)
if ev != nil {
if ev == nil {
return 0, errors.New("invalid value for enum %v: %s", ed.FullName(), name)
}
return ev.Number(), nil