mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-29 23:20:49 +03:00
parent
7bcc1ce659
commit
dbbc5c4810
2 changed files with 16 additions and 0 deletions
|
@ -494,6 +494,7 @@ type intersector struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *intersector) appendIfNotSeen(v reflect.Value) {
|
func (i *intersector) appendIfNotSeen(v reflect.Value) {
|
||||||
|
|
||||||
vi := v.Interface()
|
vi := v.Interface()
|
||||||
if !i.seen[vi] {
|
if !i.seen[vi] {
|
||||||
i.r = reflect.Append(i.r, v)
|
i.r = reflect.Append(i.r, v)
|
||||||
|
@ -565,6 +566,14 @@ func (ns *Namespace) Union(l1, l2 interface{}) (interface{}, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !l1vv.IsValid() {
|
||||||
|
// The first slice may be empty. Pick the first value of the second
|
||||||
|
// to use as a prototype.
|
||||||
|
if l2v.Len() > 0 {
|
||||||
|
l1vv = l2v.Index(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for j := 0; j < l2v.Len(); j++ {
|
for j := 0; j < l2v.Len(); j++ {
|
||||||
l2vv := l2v.Index(j)
|
l2vv := l2v.Index(j)
|
||||||
|
|
||||||
|
|
|
@ -666,6 +666,13 @@ func TestUnion(t *testing.T) {
|
||||||
{pagesVals{p1v}, pagesVals{p3v, p3v}, pagesVals{p1v, p3v}, false},
|
{pagesVals{p1v}, pagesVals{p3v, p3v}, pagesVals{p1v, p3v}, false},
|
||||||
{[]interface{}{p1, p4}, []interface{}{p4, p2, p2}, []interface{}{p1, p4, p2}, false},
|
{[]interface{}{p1, p4}, []interface{}{p4, p2, p2}, []interface{}{p1, p4, p2}, false},
|
||||||
{[]interface{}{p1v}, []interface{}{p3v, p3v}, []interface{}{p1v, p3v}, false},
|
{[]interface{}{p1v}, []interface{}{p3v, p3v}, []interface{}{p1v, p3v}, false},
|
||||||
|
// #3686
|
||||||
|
{[]interface{}{p1v}, []interface{}{}, []interface{}{p1v}, false},
|
||||||
|
{[]interface{}{}, []interface{}{p1v}, []interface{}{p1v}, false},
|
||||||
|
{pagesPtr{p1}, pagesPtr{}, pagesPtr{p1}, false},
|
||||||
|
{pagesVals{p1v}, pagesVals{}, pagesVals{p1v}, false},
|
||||||
|
{pagesPtr{}, pagesPtr{p1}, pagesPtr{p1}, false},
|
||||||
|
{pagesVals{}, pagesVals{p1v}, pagesVals{p1v}, false},
|
||||||
|
|
||||||
// errors
|
// errors
|
||||||
{"not array or slice", []string{"a"}, false, true},
|
{"not array or slice", []string{"a"}, false, true},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue