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
1 changed files with 11 additions and 5 deletions

View File

@ -597,12 +597,18 @@ impl Term<Name> {
Term::less_than_equals_integer() Term::less_than_equals_integer()
.apply(Term::integer(2.into())) .apply(Term::integer(2.into()))
.apply(Term::fst_pair().apply(pair.clone())) .apply(Term::fst_pair().apply(pair.clone()))
.if_then_else(
otherwise.clone(),
Term::less_than_integer()
.apply(Term::fst_pair().apply(pair.clone()))
.apply(Term::integer(0.into()))
.if_then_else( .if_then_else(
otherwise.clone(), otherwise.clone(),
callback( callback(
Term::equals_integer() Term::equals_integer()
.apply(Term::fst_pair().apply(pair)) .apply(Term::integer(1.into()))
.apply(Term::integer(1.into())), .apply(Term::fst_pair().apply(pair)),
),
), ),
), ),
otherwise.clone(), otherwise.clone(),