Expand keyword-in-ref coverage for complex parser edge cases (interpreter + RVM)#744
Open
Copilot wants to merge 5 commits into
Open
Expand keyword-in-ref coverage for complex parser edge cases (interpreter + RVM)#744Copilot wants to merge 5 commits into
Copilot wants to merge 5 commits into
Conversation
Copilot
AI
changed the title
[WIP] Add keywords_in_refs capability to allow reserved keywords as field names
parser: allow reserved keywords as field names in dot-notation refs (keywords_in_refs)
Jun 9, 2026
Copilot
AI
changed the title
parser: allow reserved keywords as field names in dot-notation refs (keywords_in_refs)
Expand keyword-in-ref coverage for complex parser edge cases (interpreter + RVM)
Jun 9, 2026
anakrish
approved these changes
Jun 11, 2026
There was a problem hiding this comment.
Pull request overview
This PR expands keyword-in-reference parsing support in the core Rego parser so that reserved keywords (and imported future keywords) can be used as dot-notation field names (e.g. input.package.format, data.words.if.default.value) without being rejected as keywords. It then adds interpreter and RVM regression tests to exercise these edge-case reference shapes and ensure execution-path parity.
Changes:
- Added
Parser::parse_ref_field()to accept anyTokenKind::Identas a ref field segment after.(including keyword spellings). - Updated ref/path/rule-head parsing to use
parse_ref_field()instead ofparse_var()/parse_ident()for dot segments. - Added/extended YAML test coverage for keyword segments in refs (interpreter + RVM), including package/import paths and dynamic bracket indexing mixed with keyword dot access.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/parser.rs |
Allows keyword spellings as dot-notation ref field segments by introducing parse_ref_field() and wiring it into ref/path/rule-ref parsing. |
tests/rvm/rego/cases/chained_access.yaml |
Adds RVM cases covering keyword segments in refs across package fields, package/import paths, rule-head refs, and mixed dot+dynamic bracket access. |
tests/interpreter/cases/refr/keywords_in_refs.yaml |
Adds interpreter coverage for keywords-as-field-names in dot refs, including reserved keywords and selected complex edge shapes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The existing keyword-in-ref tests covered common cases but missed several high-value parser edge paths. This update broadens coverage to ensure keyword field handling is exercised in complex and corner-case reference shapes across both execution paths.
Interpreter coverage: complex keyword ref scenarios
/tests/interpreter/cases/refr/keywords_in_refs.yamlwith cases for:import future.keywordspackagepathsimportpathsRVM parity coverage
/tests/rvm/rego/cases/chained_access.yamlso RVM exercises the same reference patterns and semantics as interpreter coverage.Result-shape consistency