Skip to content

Commit

Permalink
internal/cuetxtar: error on txtar files with duplicate file entries
Browse files Browse the repository at this point in the history
These could go unnoticed for a while as txtar allows them
and our code happily let the last duplicated file entry win.

There were two such duplicates already, both in cycle/issue990.txtar.

Signed-off-by: Daniel Martí <[email protected]>
Change-Id: Idb29d272534a09e455c01291a4bb20ff7df51c93
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1200855
TryBot-Result: CUEcueckoo <[email protected]>
Reviewed-by: Roger Peppe <[email protected]>
  • Loading branch information
mvdan committed Sep 10, 2024
1 parent 15fbf7f commit 74a06f8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
12 changes: 0 additions & 12 deletions cue/testdata/cycle/issue990.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,6 @@ out.subs.subs.#p: invalid structural cycle
This seems to be the result of incorrect handling of disjunctions.
-- diff/todo/p3 --
Reordering
-- diff/todo/p3 --
Reordering
-- out/evalalpha/stats --
Leaks: 2604
Freed: 263
Reused: 263
Allocs: 2604
Retain: 0

Unifications: 239
Conjuncts: 8656
Disjuncts: 522
-- out/evalalpha/stats --
Leaks: 2075
Freed: 218
Expand Down
3 changes: 3 additions & 0 deletions internal/cuetxtar/txtar.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,9 @@ func (x *TxTarTest) run(t *testing.T, m *cuetdtest.M, f func(tc *Test)) {
// Track the position of the fallback files.
index := make(map[string]int, len(a.Files))
for i, f := range a.Files {
if _, ok := index[f.Name]; ok {
t.Errorf("duplicated txtar file entry %s", f.Name)
}
index[f.Name] = i
}

Expand Down

0 comments on commit 74a06f8

Please sign in to comment.