We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OptionEq
OptionEq is a patch that allows comparison of optional types. However, the current implementation is broken.
C = Class { .x = Int } C|<: Eq|. __eq__ self, other: C = self.x == other.x c as C or NoneType = C.new { .x = 1 } print! c == None
False
AttributeError: 'NoneType' object has no attribute 'x'
It should be:
C|<: Eq|. __eq__ self, other: C = hasattr(other, "x") and self.x == other.x
But this doesn't mean the original implementation was wrong. It is an implementation mistake that OptionEq allows T or NoneType <: Eq for T <: Eq.
T or NoneType <: Eq
T <: Eq
To allow this, we need to inject an implementation like, for example:
OptionEq. __eq__ slf, other = classof(slf) == classof(other) and slf.__eq__ other c as C or NoneType = C.new { .x = 1 } print! OptionEq.__eq__ c, None
0.6.33
None
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Describe the behavior?
OptionEq
is a patch that allows comparison of optional types. However, the current implementation is broken.Reproducible code
Expected result
False
Actual result
AttributeError: 'NoneType' object has no attribute 'x'
Additional context
It should be:
But this doesn't mean the original implementation was wrong.
It is an implementation mistake that
OptionEq
allowsT or NoneType <: Eq
forT <: Eq
.To allow this, we need to inject an implementation like, for example:
Erg version
0.6.33
Python version
None
OS
None
The text was updated successfully, but these errors were encountered: