don't compile is instruction if bound to anonymous variable (#1974)

This commit is contained in:
Mark
2023-08-29 15:26:08 -06:00
parent 78b35dc57d
commit 53a1be78cc

View File

@@ -804,15 +804,27 @@ impl<'b> CodeGenerator<'b> {
&Term::Var(ref vr, ref name) => {
let var_num = name.to_var_num().unwrap();
self.marker.mark_var::<QueryInstruction>(
var_num,
Level::Shallow,
vr,
term_loc,
code,
);
if self.marker.var_data.records[var_num].num_occurrences > 1 {
self.marker.mark_var::<QueryInstruction>(
var_num,
Level::Shallow,
vr,
term_loc,
code,
);
self.marker.mark_safe_var_unconditionally(var_num);
self.marker.mark_safe_var_unconditionally(var_num);
} else {
if self.marker.in_tail_position {
if self.marker.var_data.allocates {
code.push_back(instr!("deallocate"));
}
code.push_back(instr!("proceed"));
}
return Ok(());
}
compile_expr!(self, &terms[1], term_loc, code)
}