From 74a06f8b80e2b33743fc088c71ff31ee6c468f90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Tue, 10 Sep 2024 17:29:28 +0100 Subject: [PATCH] internal/cuetxtar: error on txtar files with duplicate file entries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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í Change-Id: Idb29d272534a09e455c01291a4bb20ff7df51c93 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1200855 TryBot-Result: CUEcueckoo Reviewed-by: Roger Peppe --- cue/testdata/cycle/issue990.txtar | 12 ------------ internal/cuetxtar/txtar.go | 3 +++ 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/cue/testdata/cycle/issue990.txtar b/cue/testdata/cycle/issue990.txtar index 2a9d1b3f8c6..72c7d8efc0f 100644 --- a/cue/testdata/cycle/issue990.txtar +++ b/cue/testdata/cycle/issue990.txtar @@ -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 diff --git a/internal/cuetxtar/txtar.go b/internal/cuetxtar/txtar.go index 0fe64109564..8de05b6e0c7 100644 --- a/internal/cuetxtar/txtar.go +++ b/internal/cuetxtar/txtar.go @@ -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 }