ast: resolve local ref heads in the ground-prefix path too
`input.foo[_] == "a"`, and `input.foo[i] == "a"` with i the last element of the
ref, are indexed on the ref's ground prefix: tryIndexWildcardRef records
`input.foo = "a"` and the trie checks whether the collection found there holds
the value. That path validates the ground prefix itself and returns before
eqOperandsToRefAndValue ever sees the expression, so
p := 1 if { x := input; x.foo[_] == "a" }
p := 2 if { x := input; x.foo[_] == "b" }
had nothing indexed, while the same policy spelled `input.foo[_]` indexed fine --
the asymmetry the previous commit set out to remove, one code path over.
Resolve the head there as well. The resolution moves out of
eqOperandsToRefAndValue into resolveRefHead so both callers share it; refs
already rooted at a root document pass through unchanged, as before.
A variable that is not the last element of the ref stays unindexed either way:
the ground prefix is then shorter than len(ref)-1, and the equality path rejects
the resolved ref for not being ground.
Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com> S
Stephan Renatus committed
11c5d41febcd59622cd87f23a9d8f0b12daf171c
Parent: aebe258
Committed by Stephan Renatus <s_renatus@apple.com>
on 8/28/2026, 7:28:21 AM