11use crate :: ast_visitor:: { Action , Visitor } ;
22use fil_ast as ast;
33use fil_ast:: Loc ;
4- use fil_utils:: { Error , FilamentResult } ;
4+ use fil_utils:: { Error , FilamentResult , GPosIdx } ;
55
66/// Desugars conditional constraints into assume statements
77#[ derive( Default ) ]
@@ -48,6 +48,8 @@ impl DesugarConditionals {
4848 ) -> FilamentResult < Vec < ast:: Command > > {
4949 use ast:: FCons ;
5050
51+ let original_loc = constraint. pos ( ) ; // Capture original location
52+
5153 match & * * constraint {
5254 FCons :: ConditionalC {
5355 condition,
@@ -57,12 +59,12 @@ impl DesugarConditionals {
5759 let mut facts = Vec :: new ( ) ;
5860
5961 // Create: assume condition => then_constraint
60- let then_fact = self . create_assume_fact ( condition. clone ( ) , then_constraint) ?;
62+ let then_fact = self . create_assume_fact ( condition. clone ( ) , then_constraint, original_loc ) ?;
6163 facts. push ( ast:: Command :: Fact ( then_fact) ) ;
6264
6365 // Create: assume !condition => else_constraint
6466 let negated_condition = self . negate_condition ( condition) ?;
65- let else_fact = self . create_assume_fact ( negated_condition, else_constraint) ?;
67+ let else_fact = self . create_assume_fact ( negated_condition, else_constraint, original_loc ) ?;
6668 facts. push ( ast:: Command :: Fact ( else_fact) ) ;
6769
6870 Ok ( facts)
@@ -79,15 +81,16 @@ impl DesugarConditionals {
7981 & self ,
8082 condition : ast:: OrderConstraint < ast:: Expr > ,
8183 constraint : & ast:: FCons ,
84+ original_loc : GPosIdx ,
8285 ) -> FilamentResult < ast:: Fact > {
8386 // Convert FCons to OrderConstraint
8487 let constraint_oc = self . fcons_to_order_constraint ( constraint) ?;
8588
8689 // Create implication: condition => constraint
8790 let implication = ast:: Implication :: implies ( condition, constraint_oc) ;
8891
89- // Create assume fact
90- Ok ( ast:: Fact :: assume ( Loc :: unknown ( implication) ) )
92+ // Create assume fact with original location
93+ Ok ( ast:: Fact :: assume ( Loc :: new ( implication, original_loc ) ) )
9194 }
9295
9396 fn fcons_to_order_constraint (
0 commit comments