cuelang.org/go@v0.13.0/tools/trim/testdata/57.txtar (about) 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 #skip-v2 32 -- a.cue -- 33 if x == 5 { 34 x: 5 35 x: int 36 y: "hi" 37 } 38 x: 5 39 y: "hi" 40 -- out/trim-v3 -- 41 == a.cue 42 if x == 5 { 43 y: "hi" 44 } 45 x: 5 46 -- out/trim-v3-noshare -- 47 == a.cue 48 if x == 5 { 49 y: "hi" 50 } 51 x: 5