Skip to content

fix(parser)!: reject negated assignment and unification - #933

Open
Anand Krishnamoorthi (anakrish) wants to merge 4 commits into
microsoft:mainfrom
anakrish:fix/reject-negated-assignment
Open

Anand Krishnamoorthi (anakrish) wants to merge 4 commits into
microsoft:mainfrom
anakrish:fix/reject-negated-assignment

Conversation

@anakrish

Copy link
Copy Markdown
Collaborator

Changes

Reject direct negated := and = with a diagnostic recommending == for negated equality. Positive bindings inside nested queries remain supported.

This intentionally restricts negated = even where OPA accepts it. Update grammar documentation, parser regressions, and affected conformance tests.

Validation

Both independent local reviews passed. Parser and cross-engine regression tests, debug CI, formatting/clippy/build checks, and no_std checks passed. Six intentional OPA compatibility rejections are checked separately from conformance passes.

Require == for negated equality while retaining positive bindings inside nested queries. Track intentional OPA compatibility rejections separately from runtime conformance passes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 84271ec2-b466-4cfe-bf58-848f4dceb842
Keep a focused Rust regression for query diagnostics and engine recovery; use existing YAML runners for parser rejection and cross-engine positive cases.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 84271ec2-b466-4cfe-bf58-848f4dceb842

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Nested parse fallbacks can discard the new == guidance, and refreshing the passing list would drop arithmetic and negation conformance coverage from CI.

2 open issues
What changed in this PR

This PR tightens Regorus’s Rego parser to reject direct negated assignment and unification while preserving positive bindings inside nested queries. The unification restriction intentionally differs from OPA.

Changes:

  • Reject negated := and = with guidance to use ==.
  • Add parser and cross-engine regressions, and migrate affected differential tests to equality.
  • Document the restriction and report expected OPA compatibility rejections separately from conformance passes.
File Description
tests/​rvm/​rego/​comprehension_failure_differential.rs Updates negated comparisons to use ==.
tests/​parser/​mod.rs Adds rejection diagnostics and valid nested-binding regressions across engines.
tests/​opa.rs Separately checks and counts intentional compatibility rejections.
src/​parser.rs Rejects negated bindings and preserves errors for not-led queries.
docs/​grammar.md Explains the restriction and supported nested bindings.

Review effort: Max

Comment thread src/parser.rs Resolved
Comment thread tests/opa.rs Resolved
Treat negated-binding admission failures as terminal across parser fallbacks. Cover nested rejections behind a positive outer binding and retain passing OPA folders with intentional compatibility rejections.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 84271ec2-b466-4cfe-bf58-848f4dceb842

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The negated-unification compatibility break lacks a release warning and migration guidance, while the formal grammar and conformance documentation still contradict the new behavior.

3 open issues
2 resolved since last review

Review effort: Max

Comment thread src/parser.rs Resolved
Comment thread docs/grammar.md Resolved
Comment thread tests/opa.rs Resolved
@anakrish Anand Krishnamoorthi (anakrish) changed the title fix(parser): reject negated assignment and unification fix(parser)!: reject negated assignment and unification Nov 10, 2026
Align both grammar productions, reference lists, and the railroad diagram with the negated-binding restriction. Document the intentional OPA conformance exception and migration in the unreleased changelog.

BREAKING CHANGE: Direct negated assignment and unification are rejected, including previously accepted OPA-compatible unification. For negated equality, migrate not x = value to not x == value.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 84271ec2-b466-4cfe-bf58-848f4dceb842

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

A minor finding about duplicate differential tests was omitted from the published review, so its significance for approval requires human assessment.

No open issues 🎉

3 resolved since last review

Review effort: Max

@anakrish
Anand Krishnamoorthi (anakrish) marked this pull request as ready for review November 10, 2026 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants