mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-21 21:09:02 +00:00
targets: fail fast on duplicate values in target field slices
This commit is contained in:
+10
-1
@@ -88,8 +88,17 @@ func (spec *TargetSpec) overrideProperties(child *TargetSpec) {
|
|||||||
if !src.IsNil() {
|
if !src.IsNil() {
|
||||||
dst.Set(src)
|
dst.Set(src)
|
||||||
}
|
}
|
||||||
case reflect.Slice: // for slices, append the field
|
case reflect.Slice: // for slices, append the field and check for duplicates
|
||||||
dst.Set(reflect.AppendSlice(dst, src))
|
dst.Set(reflect.AppendSlice(dst, src))
|
||||||
|
for i := 0; i < dst.Len(); i++ {
|
||||||
|
v := dst.Index(i).String()
|
||||||
|
for j := i + 1; j < dst.Len(); j++ {
|
||||||
|
w := dst.Index(j).String()
|
||||||
|
if v == w {
|
||||||
|
panic("duplicate value '" + v + "' in field : " + field.Name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
panic("unknown field type : " + kind.String())
|
panic("unknown field type : " + kind.String())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user