From 7d6336bbc934951e38884381aaa309376794275b Mon Sep 17 00:00:00 2001 From: RenChu Wang Date: Wed, 10 Jul 2024 22:49:17 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=A5=B4=20Having=20no=20`=5F=5Fmatch=5Farg?= =?UTF-8?q?s=5F=5F`=20is=20ok.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It will simply fall into the type matching phase. --- python/src/matching.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/python/src/matching.py b/python/src/matching.py index 84ec92e..606e2db 100644 --- a/python/src/matching.py +++ b/python/src/matching.py @@ -37,6 +37,10 @@ def world(self): return "world" +class NotDecomposable: + pass + + if __name__ == "__main__": dc = DataClass(name="name", value=3) @@ -68,3 +72,16 @@ def world(self): match nested: case Nested(item=DataClass(value=val, name=nam)): print(val, nam) + + nd = NotDecomposable() + + match nd: + case NotDecomposable(): + print("Still matches.") + + try: + _ = nd.__match_args__ + + raise ValueError("Unreachable.") + except AttributeError: + pass