Skip to content

Commit

Permalink
fix: branch with unchecked cast could panic at compile time (Consensy…
Browse files Browse the repository at this point in the history
  • Loading branch information
gbotrel authored Aug 2, 2024
1 parent d8ccab5 commit ea53f37
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions frontend/cs/scs/api_assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,10 @@ func (builder *builder) AssertIsEqual(i1, i2 frontend.Variable) {
// AssertIsDifferent fails if i1 == i2
func (builder *builder) AssertIsDifferent(i1, i2 frontend.Variable) {
s := builder.Sub(i1, i2)
if c, ok := builder.constantValue(s); ok && c.IsZero() {
panic("AssertIsDifferent(x,x) will never be satisfied")
if c, ok := builder.constantValue(s); ok {
if c.IsZero() {
panic("AssertIsDifferent(x,x) will never be satisfied")
}
} else if t := s.(expr.Term); t.Coeff.IsZero() {
panic("AssertIsDifferent(x,x) will never be satisfied")
}
Expand Down

0 comments on commit ea53f37

Please sign in to comment.