Debian Codegraph @

tools/trim/testdata/57.txtar

raw
1 A variation on 25.
2
3 This test justifies tracking dependencies within winning sets.
4
5 In 25, line 4 is the only winner for y, and so it is required to
6 survive. Then, line 4 requires line 1, and line 1 requires line
7 6. Because line 6 is required, line 2 (with which line 6 is a tie),
8 can be removed.
9
10 But here, we have an additional tie, this time for y, between line 4
11 and line 7, and as such we have no "early" requirement that line 1
12 (the comprehension) survives. So we have a tie for x between lines 2
13 and 6, and a tie for y between lines 4 and 7. The tie for x gets
14 solved first.
15
16 If we did not track dependencies *within* a winning set, then the
17 following would occur:
18 1. we would choose line 2 to win (based on file position)
19 2. line 2 requires line 1
20 3. line 1 requires line 6.
21 So we would end up with both line 2 and line 6 surviving.
22
23 But because we identify dependencies between winning nodes *within*
24 the same set, we find than line 2 transitively depends on line 6, and
25 as such, when choose a winner, we make sure we choose line 6.
26
27 Having chosen the winner for x, we then chose the winner for y between
28 lines 4 and 7. This is much simpler - we have a tie of 1-1 for the
29 seenCounts, and so we just pick line 4 because 4 < 7.
30
31 -- a.cue --
32 if x == 5 {
33 x: 5
34 x: int
35 y: "hi"
36 }
37 x: 5
38 y: "hi"
39 -- out/trim-v3 --
40 == a.cue
41 if x == 5 {
42 y: "hi"
43 }
44 x: 5
45 -- out/trim-v3-noshare --
46 == a.cue
47 if x == 5 {
48 y: "hi"
49 }
50 x: 5