Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if expression is a variable in imm after encoding #971

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 14 additions & 15 deletions crates/flux-infer/src/fixpoint_encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1224,21 +1224,20 @@ impl<'genv, 'tcx> ExprEncodingCtxt<'genv, 'tcx> {
scx: &mut SortEncodingCtxt,
bindings: &mut Vec<fixpoint::Bind>,
) -> QueryResult<fixpoint::Var> {
match arg.kind() {
rty::ExprKind::Var(var) => Ok(self.var_to_fixpoint(var)),
_ => {
let fresh = self.local_var_env.fresh_name();
let pred = fixpoint::Expr::eq(
fixpoint::Expr::Var(fresh.into()),
self.expr_to_fixpoint(arg, scx)?,
);
bindings.push(fixpoint::Bind {
name: fresh.into(),
sort: scx.sort_to_fixpoint(sort),
pred: fixpoint::Pred::Expr(pred),
});
Ok(fresh.into())
}
let arg = self.expr_to_fixpoint(arg, scx)?;
// Check if it's a variable after encoding, in case the encoding produced a variable from a
// non-variable.
if let fixpoint::Expr::Var(var) = arg {
Ok(var)
} else {
let fresh = self.local_var_env.fresh_name();
let pred = fixpoint::Expr::eq(fixpoint::Expr::Var(fresh.into()), arg);
bindings.push(fixpoint::Bind {
name: fresh.into(),
sort: scx.sort_to_fixpoint(sort),
pred: fixpoint::Pred::Expr(pred),
});
Ok(fresh.into())
}
}

Expand Down
Loading