Fix bool soft-casting.

While the ledger doesn't allow deserializing negative constr value,
  they are still possible at the machine level. So, we better make sure
  that we don't make assumptions regarding this.
This commit is contained in:
KtorZ
2024-08-01 13:08:29 +02:00
committed by Kasey
parent 9610237616
commit ea8003af8f

View File

@@ -599,11 +599,17 @@ impl Term<Name> {
.apply(Term::fst_pair().apply(pair.clone()))
.if_then_else(
otherwise.clone(),
callback(
Term::equals_integer()
.apply(Term::fst_pair().apply(pair))
.apply(Term::integer(1.into())),
),
Term::less_than_integer()
.apply(Term::fst_pair().apply(pair.clone()))
.apply(Term::integer(0.into()))
.if_then_else(
otherwise.clone(),
callback(
Term::equals_integer()
.apply(Term::integer(1.into()))
.apply(Term::fst_pair().apply(pair)),
),
),
),
otherwise.clone(),
)