feat: Handle computed reference roots in RVM compiler

Allow compile_chained_ref to fall back to “evaluate root expression → chain access”
so literal arrays, comprehensions, and other computed roots no longer raise NotSimpleReferenceChain.

Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
Anand Krishnamoorthi
2025-12-03 11:00:57 -06:00
parent e3d23766ae
commit 8269968c4a
3 changed files with 70 additions and 20 deletions
-4
View File
@@ -32,15 +32,11 @@ const OPA_TODO_FOLDERS: &[&str] = &[
"example",
"fix1863",
"functions",
"jsonschema",
"partialdocconstants",
"partialobjectdoc",
"planner-ir",
"refheads",
"replacen",
"semverisvalid",
"sets",
"time",
"type",
"varreferences",
"virtualdocs",
+24
View File
@@ -196,6 +196,30 @@ cases:
query: data.test.main
want_result: "web1"
- note: literal_array_root_access
data: {}
modules:
- |
package test
y := ["x", "y"][1]
main := y
query: data.test.main
want_result: "y"
- note: computed_object_root_access
data: {}
modules:
- |
package test
x := strings.replace_n({k: v | k := ["f", "foo"][i]; v := ["x", "xxx"][i]}, "foo")
main := x
query: data.test.main
want_result: "xoo"
- note: string_literal_bracket_access
data: {}
modules: