internal/core/adt: refine cycle handling in LetReference.resolve
This fix addresses a regression where reordering fields in data files
caused spurious cycle errors. The original check was too restrictive,
only allowing early return of an arc if it was not being evaluated.
Allow returning a let arc early if it contains a cycle placeholder,
regardless of whether it is currently being evaluated.
This allows the caller to handle the cycle appropriately,
such as by allowing it in an interpolation if it eventually resolves.
We maintain the arcState nil check for arcs with no value yet (b == nil)
to prevent infinite recursion and hangs on cycles through 'let'.
Fixes #4244.
Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: Idca80aa44745cc79ad8e2443faf53f4aa4e23be4
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1230698
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Marcel van Lohuizen <mpvl@gmail.com>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>