Fix merging a key into a nil target

When merging a key where the target value is nil, the type of the target
and source do not match. What currently happens is an error is logged
and the key is skipped.

I have changed it so that it does the same thing as when the target key
is missing: copy the source value to the target.

Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
This commit is contained in:
Carolyn Van Slyck 2021-05-12 17:09:19 -05:00 committed by Márk Sági-Kazár
parent 36be6bf91f
commit cdb5e5976f
2 changed files with 2 additions and 1 deletions

View file

@ -1826,7 +1826,7 @@ func mergeMaps(
svType := reflect.TypeOf(sv)
tvType := reflect.TypeOf(tv)
if svType != tvType {
if tvType != nil && svType != tvType { // Allow for the target to be nil
jww.ERROR.Printf(
"svType != tvType; key=%s, st=%v, tt=%v, sv=%v, tv=%v",
sk, svType, tvType, sv, tv)

View file

@ -1695,6 +1695,7 @@ hello:
pop: 37890
largenum: 765432101234567
num2pow63: 9223372036854775808
universe: null
world:
- us
- uk