@@ -22,6 +22,9 @@ pub enum LangError {
2222
2323 #[ error( "Lowering error: {0}" ) ]
2424 Lowering ( Box < LoweringError > ) ,
25+
26+ #[ error( "Batching error: {0}" ) ]
27+ Batching ( Box < BatchingError > ) ,
2528}
2629
2730/// Validation errors from frontend AST validation
@@ -90,14 +93,6 @@ pub enum ValidationError {
9093/// Lowering errors from frontend AST lowering to middleware
9194#[ derive( Debug , thiserror:: Error ) ]
9295pub enum LoweringError {
93- #[ error( "Too many custom predicates in batch '{batch_name}': {count} exceeds limit of {max}{}" , if * . original_count != * . count { format!( " (started with {} predicates before automatic splitting)" , original_count) } else { String :: new( ) } ) ]
94- TooManyPredicates {
95- batch_name : String ,
96- count : usize ,
97- max : usize ,
98- original_count : usize ,
99- } ,
100-
10196 #[ error( "Too many statements in predicate '{predicate}': {count} exceeds limit of {max}" ) ]
10297 TooManyStatements {
10398 predicate : String ,
@@ -127,6 +122,9 @@ pub enum LoweringError {
127122 #[ error( "Splitting error: {0}" ) ]
128123 Splitting ( #[ from] SplittingError ) ,
129124
125+ #[ error( "Batching error: {0}" ) ]
126+ Batching ( #[ from] BatchingError ) ,
127+
130128 #[ error( "Cannot lower document with validation errors" ) ]
131129 ValidationErrors ,
132130}
@@ -235,6 +233,21 @@ fn format_public_args_at_split_error(
235233 msg
236234}
237235
236+ /// Batching errors from multi-batch packing
237+ #[ derive( Debug , thiserror:: Error ) ]
238+ pub enum BatchingError {
239+ #[ error( "Forward cross-batch reference: predicate '{caller}' (batch {caller_batch}) calls '{callee}' (batch {callee_batch}). Move '{callee}' earlier or '{caller}' later." ) ]
240+ ForwardCrossBatchReference {
241+ caller : String ,
242+ caller_batch : usize ,
243+ callee : String ,
244+ callee_batch : usize ,
245+ } ,
246+
247+ #[ error( "Internal batching error: {message}" ) ]
248+ Internal { message : String } ,
249+ }
250+
238251/// Splitting errors from predicate splitting
239252#[ derive( Debug , thiserror:: Error ) ]
240253pub enum SplittingError {
@@ -271,13 +284,6 @@ pub enum SplittingError {
271284 max_allowed : usize ,
272285 suggestion : Option < Box < RefactorSuggestion > > ,
273286 } ,
274-
275- #[ error( "Too many predicates in chain for '{predicate}': {count} exceeds batch limit of {max_allowed}" ) ]
276- TooManyPredicatesInChain {
277- predicate : String ,
278- count : usize ,
279- max_allowed : usize ,
280- } ,
281287}
282288
283289impl From < ParseError > for LangError {
@@ -303,3 +309,9 @@ impl From<LoweringError> for LangError {
303309 LangError :: Lowering ( Box :: new ( err) )
304310 }
305311}
312+
313+ impl From < BatchingError > for LangError {
314+ fn from ( err : BatchingError ) -> Self {
315+ LangError :: Batching ( Box :: new ( err) )
316+ }
317+ }
0 commit comments