Skip to content

Commit

Permalink
Fix type inference for body constructors (#436)
Browse files Browse the repository at this point in the history
  • Loading branch information
monsterkrampe authored Nov 30, 2023
1 parent fbff682 commit c3d7b8a
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions nemo/src/program_analysis/type_inference/position_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,23 +151,22 @@ impl PositionGraph {
}

for constructor in rule.constructors() {
// Note that the head variable for constructors is unique so we can get the first entry of this vector
for head_position in variables_to_head_positions
.get(constructor.variable())
.expect("The loop at the top went through all head atoms")
.unwrap_or(&vec![])
{
for term in constructor.term().primitive_terms() {
if let PrimitiveTerm::Variable(body_variable) = term {
let body_position = variables_to_last_node
.get(body_variable)
.expect("The iteration above went through all body atoms")
.clone();
let body_position_opt =
variables_to_last_node.get(body_variable).cloned();

graph.add_edge(
body_position,
head_position.clone(),
PositionGraphEdge::BodyToHeadSameVariable,
);
if let Some(body_position) = body_position_opt {
graph.add_edge(
body_position,
head_position.clone(),
PositionGraphEdge::BodyToHeadSameVariable,
);
}
}
}
}
Expand Down

0 comments on commit c3d7b8a

Please sign in to comment.