Skip to content

Commit 99f0908

Browse files
thiremaniclaude
andcommitted
test(cond): pin whole-array values through && — copy, keep-old, fallback
An array is one value slot, so a scalar condition gates it as a unit: the borrowed right side is copied only on the yielding path, and failure keeps an existing destination, zero-seeds a fresh one, or takes the || fallback. Leak-checked via the suite. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 25406c7 commit 99f0908

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

tests/cond/logical_and.exp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ CvArrTrue: [1 5 3]
1616
CvArrFalse: [1 0 3]
1717
CvArrMulti: [9 0 7]
1818
CvArrFb: [-1 7]
19+
CvWholeArrTrue: [2 4 6]
20+
CvWholeArrBefore: [9 9]
21+
CvWholeArrOld: [9 9]
22+
CvWholeArrFresh: []
23+
CvWholeArrFb: [7 8]
1924
CvFloat: 2.5
2025
CvStrTrue: hello world
2126
re:CvStrFalse:\s*

tests/cond/logical_and.spt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,21 @@ cvArrMulti = [(a > 2 && 9) (b > 2 && 9) (a > 0 && 7)]
7979
cvArrFb = [(b > 2 && 5 || -1) 7]
8080
"CvArrFb: -cvArrFb"
8181

82+
# Whole-array value: an array is one value slot, so a scalar condition gates
83+
# the array as a unit. The right side is copied only on the yielding path;
84+
# failure keeps an existing destination, zero-seeds a fresh one, or falls back.
85+
cvWholeArr = [2 4 6]
86+
cvWholeArrTrue = a > 2 && cvWholeArr
87+
"CvWholeArrTrue: -cvWholeArrTrue"
88+
cvWholeArrOld = [9 9]
89+
"CvWholeArrBefore: -cvWholeArrOld"
90+
cvWholeArrOld = b > 2 && cvWholeArr
91+
"CvWholeArrOld: -cvWholeArrOld"
92+
cvWholeArrFresh = b > 2 && cvWholeArr
93+
"CvWholeArrFresh: -cvWholeArrFresh"
94+
cvWholeArrFb = b > 2 && cvWholeArr || [7 8]
95+
"CvWholeArrFb: -cvWholeArrFb"
96+
8297
# Float value.
8398
f = 2.5
8499
cvFloat = a > 2 && f

0 commit comments

Comments
 (0)