leo icon indicating copy to clipboard operation
leo copied to clipboard

[Feature] Eq for circuits

Open 0rphon opened this issue 3 years ago • 3 comments

🚀 Feature

right now attempting to use == on circuits causes the following error

circuit One {
    x: u8,
}
function main () {
    let x = One {x: 5};
    let y = One {x: 3};
    if x == y {
        console.log("test");
    }
}
Error:     --> "d:\\Work\\leo_playground\\src/main.leo": 8:8
     |
   8 |      if x == y {
     |         ^^^^^^
     |
     = no implementation for `One {x: 5} == One {x: 3}`

the current workaround to this is to decompose a circuit into its individual fields and compare them separately, like so:

circuit One {
    x: u8,
}
function main () {
    let x = One {x: 5};
    let y = One {x: 3};
    if x.x == y.x {
        console.log("test");
    }
}

while this works, its not as straightforward to the user as implementing Eq on circuits would be

0rphon avatar Feb 12 '21 02:02 0rphon

Possibly closed by #1375 The above example builds on the IR branch

d0cd avatar Sep 30 '21 21:09 d0cd

Deleting "Icebox" board so this issue will be moved to "New Issues"

collinc97 avatar Feb 16 '22 20:02 collinc97

Hey @collinc97, is this issue still open? I know some devs who'd be interested in working on this. If you have a budget for it, I can put this issue up on OpenQ, free of charge.

Thanks!

ef3n9r98 avatar Dec 02 '22 18:12 ef3n9r98