Address review feedback: improve parse_ref_field doc comment and clean up test comment

This commit is contained in:
copilot-swe-agent[bot]
2026-06-09 17:25:26 +00:00
committed by GitHub
parent c22f148778
commit c7216d8c66
2 changed files with 14 additions and 4 deletions
+14 -3
View File
@@ -354,9 +354,20 @@ impl<'source> Parser<'source> {
}
}
// Parse a field name after `.` in a ref expression.
// Keywords are allowed as field names in dot-notation (e.g. `input.package.name`),
// matching OPA's `keywords_in_refs` behavior which is enabled by default.
/// Parse a field name after `.` in a ref expression.
///
/// Unlike [`Self::parse_var`] and [`Self::parse_ident`], this method accepts **any**
/// `TokenKind::Ident` token, including reserved keywords (e.g. `as`, `default`, `else`,
/// `false`, `if`, `import`, `in`, `not`, `null`, `package`, `some`, `true`, `with`).
///
/// The position immediately after `.` is unambiguously a field name, so there is no
/// syntactic ambiguity with statement-level keywords. This matches OPA's
/// `keywords_in_refs` capability, which is enabled by default in standard OPA builds.
///
/// # Example
/// ```rego
/// allow if { input.v0.package.format == "npm" } # `package` is a keyword but valid here
/// ```
fn parse_ref_field(&mut self) -> Result<Span> {
let span = self.tok.1.clone();
match self.tok.0 {
@@ -3,7 +3,6 @@
#
# Tests for keywords-as-field-names in dot-notation refs.
# Matches OPA's `keywords_in_refs` behavior, enabled by default.
# See: https://github.com/microsoft/regorus/issues/XXX
cases:
- note: keywords_in_refs/package field
modules: