Closed
Description
I tried this:
struct Cat {
name: str;
age: num;
}
let cat1 = Cat { name: "Mittens", age: 3 };
let cat2 = Cat { name: "Mittens", age: 3 };
assert(cat1 == cat2); // fields and types match
This happened:
ERROR: assertion failed: '(cat1 === cat2)'
target/equality.wsim.725637.tmp/.wing/preflight.js:24
"age": 3,}
;
>> {((cond) => {if (!cond) throw new Error(`assertion failed: '(cat1 === cat2)'`)})((cat1 === cat2))};
{((cond) => {if (!cond) throw new Error(`assertion failed: '(cat1 !== cat3)'`)})((cat1 !== cat3))};
}
I expected this:
It compiles
Is there a workaround?
Write a custom equality function that checks if each field is equal
Component
Compiler
Wing Version
0.19.14
Wing Console Version
No response
Node.js Version
18.14.1
Platform(s)
MacOS
Anything else?
No response
Community Notes
- Please vote by adding a 👍 reaction to the issue to help us prioritize.
- If you are interested to work on this issue, please leave a comment.
Metadata
Metadata
Assignees
Type
Projects
Status
✅ Done