encoding/json: recover saved error context when unmarshalling

Fixes: #27464

Change-Id: I270c56fd0d5ae8787a1293029aff3072f4f52f33
Reviewed-on: https://go-review.googlesource.com/132955
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Ian Davis 2018-09-03 11:20:23 +01:00 committed by Daniel Martí
parent 6b7099caa1
commit 22afb3571c
2 changed files with 12 additions and 1 deletions

View file

@ -179,7 +179,7 @@ func (d *decodeState) unmarshal(v interface{}) error {
// test must be applied at the top level of the value.
err := d.value(rv)
if err != nil {
return err
return d.addErrorContext(err)
}
return d.savedError
}