diff --git a/pkg/composableschemadsl/compiler/translator.go b/pkg/composableschemadsl/compiler/translator.go index 927c963e17..ee6dfc6f39 100644 --- a/pkg/composableschemadsl/compiler/translator.go +++ b/pkg/composableschemadsl/compiler/translator.go @@ -23,7 +23,7 @@ type translationContext struct { mapper input.PositionMapper schemaString string skipValidate bool - existingNames []string + existingNames *mapz.Set[string] sourceFolder string } @@ -51,7 +51,9 @@ func translate(tctx translationContext, root *dslNode) (*CompiledSchema, error) var objectDefinitions []*core.NamespaceDefinition var caveatDefinitions []*core.CaveatDefinition - names := mapz.NewSet(tctx.existingNames...) + // Copy the name set so that we're not mutating the parent's context + // as we do our walk + names := tctx.existingNames.Copy() for _, topLevelNode := range root.GetChildren() { switch topLevelNode.GetType() {