Open myitcv opened 1 year ago
Is this a regression? If so, do you have a bisection?
Here is a simplified reproducer:
res: {
#X[3] // Must be at least 3 to cause structural cycle.
// expanding comprehension eliminates cycle.
#X: ["X", for i, _ in #subs {#s, #str: #X[i]}]
}
#s: {#str: string, #str + "a"}
#subs: [0, 1, 2]
The embedding (#X[3]
) is needed to cause a back-to-front evaluation chain which visits the same nodes in a nested fashion. Expanding the comprehension eliminates the structural cycle. This tells me that the issue probably is that comprehension elements are not treated as a "new" node and thus do not disable cycle detection. Comprehension elements should behave exactly the same as if their expressions were expanded, of course.
Apologies, I don't know why I didn't bisect this off the bat.
Just updated my repro above because in bisecting I realised the test doesn't pass when it should because the 3rd substitution causes an additional replace.
With the change my script bisects to 887f56497cbc2178e9cb1e9be78d8abae78ea0cd.
For completeness' sake, your repro bisects to the same commit.
Updated the original description to remove my environment-specific setup.
And to confirm this is a regression since v0.4.3, not since v0.5.0.
Since we are very close to the final v0.6.0 release (https://github.com/cue-lang/cue/milestone/9) and this issue is neither a regression from v0.5.0 nor a critical bug like a panic, I'm pushing it back slightly to v0.7, which we'll start working on as soon as v0.6.0 is out.
What version of CUE are you using (
cue version
)?Does this issue reproduce with the latest release?
Yes it does with ee55e9a263da
What did you do?
What did you expect to see?
Passing test.
What did you see instead?
i.e. using three substitutions instead of two triggers a structural cycle, even though (in this situation) the additional substitution is identical to the previous two substitutions.