Skip to content

Commit

Permalink
fix: Incorrect typing of vector operations (#175)
Browse files Browse the repository at this point in the history
A problem was arising related to the typing of vector operations.
Specifically, it was being considered that e.g. a `binary` value added
to another `binary` value produced a `binary` value. This corrects those
problems, but there remain some mysteries around typing.
  • Loading branch information
DavePearce authored Jun 5, 2024
1 parent c729dbc commit f6257a1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions src/compiler/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,11 @@ impl Intrinsic {
Intrinsic::Add | Intrinsic::Sub | Intrinsic::Neg => {
// Boolean is a corner case, as it is not stable under these operations
let max_t = max_type(argtype)?;
match max_t.m().rm() {
RawMagma::Binary => max_t.with_raw_magma(RawMagma::Native),
_ => max_t,
}
max_t.with_raw_magma(RawMagma::Native)
}
Intrinsic::VectorAdd | Intrinsic::VectorSub | Intrinsic::VectorMul => {
super::max_type(argtype.iter())?
let max_t = super::max_type(argtype.iter())?;
max_t.with_raw_magma(RawMagma::Native)
}
Intrinsic::Exp => argtype[0],
Intrinsic::Mul => argtype.iter().max().cloned().unwrap_or(Type::INFIMUM),
Expand Down
1 change: 0 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,6 @@ impl ConstraintSetBuilder {
.map(|r| r.1),
Either::Right(cs) => Ok(cs),
}?;

transformer::expand_to(&mut cs, self.expand_to, &self.auto_constraints)?;
transformer::concretize(&mut cs);
Ok(cs)
Expand Down

0 comments on commit f6257a1

Please sign in to comment.