Dennis Sweeney <[email protected]> added the comment:
This code...
match my_maybe:
case Maybe.empty:
print('FIRST CASE')
case _:
print('DEFAULT CASE')
... is roughly equivalent to this code:
if my_maybe == Maybe.empty:
print('FIRST CASE')
case _:
print('DEFAULT CASE')
I don't think this is a bug in the match/case compiler, I think it's simply a
matter of how Maybe() == Maybe() evaluates. Since your __new__ code always
returns the same object, Maybe() == Maybe() will return True. But by default,
each Maybe() call constructs a new instance that won't be equal to any others.
----------
nosy: +Dennis Sweeney
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue44617>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com