Skip to content

Commit

Permalink
mc: use proc span to build post
Browse files Browse the repository at this point in the history
this avoids a panic when trying to translate a proc without a post,
because the associated diagnostic would be placed in the dummy file
which is not allowed (and wrong).
  • Loading branch information
Philipp15b committed Dec 30, 2024
1 parent 82bcc00 commit df13235
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/mc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ pub fn proc_to_model(
let spec_part = SpecAutomaton::new(proc.direction);
let mut verify_unit = verify_proc(proc).unwrap();
let property = extract_properties(
proc.span,
&spec_part,
&mut verify_unit.block.node,
options.skip_quant_pre,
Expand Down
6 changes: 4 additions & 2 deletions src/mc/specs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ pub struct JaniPgclProperties {
}

pub fn extract_properties(
proc_span: Span,
spec_part: &SpecAutomaton,
stmts: &mut Vec<Stmt>,
skip_quant_pre: bool,
Expand All @@ -180,7 +181,7 @@ pub fn extract_properties(
let can_diverge = mk_can_diverge_property(spec_part, "can_diverge");

let restrict_initial = extract_preconditions(spec_part, stmts, skip_quant_pre)?;
let sink_reward = extract_post(spec_part, stmts)?;
let sink_reward = extract_post(proc_span, spec_part, stmts)?;

Ok(JaniPgclProperties {
restrict_initial,
Expand Down Expand Up @@ -313,6 +314,7 @@ fn extract_preconditions(
///
/// These (co)assert statements may be quantitative.
fn extract_post(
proc_span: Span,
spec_part: &SpecAutomaton,
stmts: &mut Vec<Stmt>,
) -> Result<Expression, JaniConversionError> {
Expand All @@ -333,7 +335,7 @@ fn extract_post(
}
}

let expr_builder = ExprBuilder::new(Span::dummy_span());
let expr_builder = ExprBuilder::new(proc_span);
let bin_op = spec_part.direction.map(BinOpKind::Inf, BinOpKind::Sup);
let sink_reward = posts
.into_iter()
Expand Down

0 comments on commit df13235

Please sign in to comment.