feat: Reject with keyword usage

RVM does not plan to support the `with` keyword which is mainly used
for testing.

- introduce CompilerError::WithKeywordUnsupported and fail query compilation
  when any literal carries with_mods
- skip OPA test cases that hit the error

The "withkeyword" folder is retained in the TODO list to indicate its
lack of support.

Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
Anand Krishnamoorthi
2025-12-03 15:22:12 -06:00
parent a514e8da83
commit d0fa639bb8
4 changed files with 24 additions and 3 deletions

View File

@@ -15,6 +15,9 @@ pub enum CompilerError {
#[error("Unknown builtin function: {name}")]
UnknownBuiltinFunction { name: String },
#[error("the `with` keyword is not supported by the compiler yet")]
WithKeywordUnsupported,
#[error("internal: missing context for yield")]
MissingYieldContext,

View File

@@ -10,7 +10,7 @@ mod queries;
mod references;
mod rules;
pub use error::{CompilerError, Result};
pub use error::{CompilerError, Result, SpannedCompilerError};
use crate::ast::ExprRef;
use crate::lexer::Span;

View File

@@ -38,6 +38,9 @@ impl<'a> Compiler<'a> {
stmts: &[&LiteralStmt],
) -> Result<()> {
for (idx, stmt) in stmts.iter().enumerate() {
if !stmt.with_mods.is_empty() {
return Err(CompilerError::WithKeywordUnsupported.at(&stmt.span));
}
let loop_exprs = self.get_statement_loops(stmt)?;
if !loop_exprs.is_empty() {