mirror of
https://github.com/microsoft/regorus.git
synced 2026-08-05 02:16:11 +00:00
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:
@@ -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,
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user