ref: 2159d77f368eb1f78e51dd94133554f88052d85f
parent: 821adf3ae877fdddce67afcccd751d47f4589538
author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
date: Thu Oct 11 07:05:30 EDT 2018
common/collections: Fix type checking in Append The fix introduced in Hugo `0.49.1` had an unintended side-effect in the `Append` func used in both `append` and `.Scratch.Add`. This commit fixes that by loosen/fixing the type checking so concrete types can be appended to interface slices. Fixes #5303
--- a/common/collections/append.go
+++ b/common/collections/append.go
@@ -59,7 +59,7 @@
for _, f := range from {fv := reflect.ValueOf(f)
- if tot != fv.Type() {+ if !fv.Type().AssignableTo(tot) { return nil, fmt.Errorf("append element type mismatch: expected %v, got %v", tot, fv.Type())}
tov = reflect.Append(tov, fv)
--- a/common/collections/append_test.go
+++ b/common/collections/append_test.go
@@ -43,7 +43,13 @@
tstSlicers{&tstSlicer{"a"}, &tstSlicer{"b"}, &tstSlicer{"c"}}},+ {testSlicerInterfaces{&tstSlicerIn1{"a"}, &tstSlicerIn1{"b"}},+ []interface{}{&tstSlicerIn1{"c"}},+ testSlicerInterfaces{&tstSlicerIn1{"a"}, &tstSlicerIn1{"b"}, &tstSlicerIn1{"c"}}},// Errors
+ {testSlicerInterfaces{&tstSlicerIn1{"a"}, &tstSlicerIn1{"b"}},+ []interface{}{"c"},+ false},
{"", []interface{}{[]string{"a", "b"}}, false},// No string concatenation.
{"ab",--
⑨