summaryrefslogtreecommitdiffstats
path: root/tpl/collections
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-12-18 21:31:34 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-12-18 21:31:34 +0100
commit1b785a7a6d3c264e39e4976c59b618c0ac1ba5f9 (patch)
treec9ccf3edd1ce9cb3c757b5938a0e578a9899723f /tpl/collections
parentd20ca3700512d661247b44d953515b9455e57ed6 (diff)
tpl/collections: Fix merge vs Params
Fixes #6633
Diffstat (limited to 'tpl/collections')
-rw-r--r--tpl/collections/merge.go2
-rw-r--r--tpl/collections/merge_test.go14
2 files changed, 15 insertions, 1 deletions
diff --git a/tpl/collections/merge.go b/tpl/collections/merge.go
index 6916d0710..39ef932ca 100644
--- a/tpl/collections/merge.go
+++ b/tpl/collections/merge.go
@@ -40,7 +40,7 @@ func (ns *Namespace) Merge(src, dst interface{}) (interface{}, error) {
return nil, errors.Errorf("source must be a map, got %T", src)
}
- if vsrc.Type() != vdst.Type() {
+ if vsrc.Type().Key() != vdst.Type().Key() {
return nil, errors.Errorf("incompatible map types, got %T to %T", src, dst)
}
diff --git a/tpl/collections/merge_test.go b/tpl/collections/merge_test.go
index a08e0021b..57163a0d5 100644
--- a/tpl/collections/merge_test.go
+++ b/tpl/collections/merge_test.go
@@ -21,6 +21,8 @@ import (
"strings"
"testing"
+ "github.com/gohugoio/hugo/common/maps"
+
"github.com/gohugoio/hugo/parser"
"github.com/gohugoio/hugo/parser/metadecoders"
@@ -57,6 +59,18 @@ func TestMerge(t *testing.T) {
map[string]interface{}{"a": 1, "b": map[string]interface{}{"d": 1, "e": 2}},
map[string]interface{}{"a": 42, "c": 3, "b": map[string]interface{}{"d": 55, "e": 66, "f": 3}},
map[string]interface{}{"a": 1, "b": map[string]interface{}{"d": 1, "e": 2, "f": 3}, "c": 3}, false},
+ {
+ // https://github.com/gohugoio/hugo/issues/6633
+ "params dst",
+ maps.Params{"a": 1, "b": 2},
+ map[string]interface{}{"a": 42, "c": 3},
+ maps.Params{"a": int(1), "b": int(2), "c": int(3)}, false},
+ {
+ // https://github.com/gohugoio/hugo/issues/6633
+ "params src",
+ map[string]interface{}{"a": 1, "c": 2},
+ maps.Params{"a": 42, "c": 3},
+ map[string]interface{}{"a": int(1), "c": int(2)}, false},
{"src nil", simpleMap, nil, simpleMap, false},
// Error cases.
{"dst not a map", "not a map", nil, nil, true},