Structural equality on JavaScript backend doesn't work
jiribenes opened this issue · comments
The structural equality on the JavaScript backend seems to be broken.
Although reflexivity (x == x
) holds for simple, user-defined types, it doesn't work for Some(x) == Some(x)
.
type MyType {
MySingleCase()
}
record EmptyRecord()
def main() = {
println(MySingleCase() == MySingleCase()) // ~> true
println(EmptyRecord() == EmptyRecord()) // ~> true
println(Some(MySingleCase()) == Some(MySingleCase())) // ~> false
println(Some(EmptyRecord()) == Some(EmptyRecord())) // ~> false
}
Line 54
is not correct, we should use equals$impl
or something similar here in order to recurse.
Currently, we compare:
- the first "layer" structurally
- the other layer just based on JavaScript's
===
equality
One should call this:
effekt/libraries/js/effekt_builtins.js
Line 13 in 3e38409