aboutsummaryrefslogtreecommitdiffhomepage
path: root/compileopts/target.go
diff options
context:
space:
mode:
authorYurii Soldak <[email protected]>2022-08-26 21:37:56 +0200
committerRon Evans <[email protected]>2022-08-29 09:44:03 +0200
commit55573c672902727b3c5b37801239972f1e8955b9 (patch)
tree2a52036725d2a3e3be5aafccdac07b3af6b36364 /compileopts/target.go
parentb8a6a1f62ba8803aaa3b9f25c8a3fcdf184eb393 (diff)
downloadtinygo-55573c672902727b3c5b37801239972f1e8955b9.tar.gz
tinygo-55573c672902727b3c5b37801239972f1e8955b9.zip
targets: fail fast on duplicate values in target field slices
Diffstat (limited to 'compileopts/target.go')
-rw-r--r--compileopts/target.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/compileopts/target.go b/compileopts/target.go
index 15bfaf781..aa2c432d4 100644
--- a/compileopts/target.go
+++ b/compileopts/target.go
@@ -88,8 +88,17 @@ func (spec *TargetSpec) overrideProperties(child *TargetSpec) {
if !src.IsNil() {
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))
+ 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:
panic("unknown field type : " + kind.String())
}