Prevent duplicate entries in ctx.include_tops
The include_tops hints are global for the whole parse
context (which is probably also something to fix), which
means that if an include_top hint is duplicated there will
be duplicated keys generated in the _entry starlark dictionary.
Bug: 193566316
Test: go test
Change-Id: I01a0546ac9be91ef46c5248e87e1a40e0f211193
diff --git a/mk2rbc/mk2rbc.go b/mk2rbc/mk2rbc.go
index 024311e..2a80e56 100644
--- a/mk2rbc/mk2rbc.go
+++ b/mk2rbc/mk2rbc.go
@@ -1629,6 +1629,13 @@
return
}
if p, ok := maybeTrim(annotation, "include_top"); ok {
+ // Don't allow duplicate include tops, because then we will generate
+ // invalid starlark code. (duplicate keys in the _entry dictionary)
+ for _, top := range ctx.includeTops {
+ if top == p {
+ return
+ }
+ }
ctx.includeTops = append(ctx.includeTops, p)
return
}