diff --git a/coconut/compiler/header.py b/coconut/compiler/header.py index 4c93eab2..e96b00c7 100644 --- a/coconut/compiler/header.py +++ b/coconut/compiler/header.py @@ -458,10 +458,10 @@ def recursive_iterator(*args, **kwargs): ''', indent=1, ), - set_nt_match_args=pycondition( + set_NT_match_args=pycondition( (3, 10), if_lt=r''' -nt.__match_args__ = nt._fields +NT.__match_args__ = _coconut.property(lambda self: self._fields) ''', indent=1, newline=True, diff --git a/coconut/compiler/templates/header.py_template b/coconut/compiler/templates/header.py_template index d0120655..0c4d503e 100644 --- a/coconut/compiler/templates/header.py_template +++ b/coconut/compiler/templates/header.py_template @@ -2023,11 +2023,10 @@ def _coconut_mk_anon_namedtuple(fields, types=None, of_kwargs={empty_dict}, of_a else: NT = _coconut.typing.NamedTuple("_namedtuple_of", [(f, t) for f, t in _coconut.zip(fields, types)]) _coconut.copyreg.pickle(NT, lambda nt: (_coconut_mk_anon_namedtuple, (nt._fields, types, nt._asdict()))) - if not (of_kwargs or of_args): +{set_NT_match_args} if of_kwargs or of_args: + return NT(*of_args, **of_kwargs) + else: return NT - nt = NT(*of_args, **of_kwargs) -{set_nt_match_args} - return nt def _coconut_ndim(arr): arr_mod = _coconut_get_base_module(arr) if (arr_mod in _coconut.numpy_modules or _coconut.hasattr(arr.__class__, "__matconcat__")) and _coconut.hasattr(arr, "ndim"): diff --git a/coconut/root.py b/coconut/root.py index a067cbd5..53f26ea2 100644 --- a/coconut/root.py +++ b/coconut/root.py @@ -26,7 +26,7 @@ VERSION = "3.1.1" VERSION_NAME = None # False for release, int >= 1 for develop -DEVELOP = 5 +DEVELOP = 6 ALPHA = False # for pre releases rather than post releases assert DEVELOP is False or DEVELOP >= 1, "DEVELOP must be False or an int >= 1" diff --git a/coconut/tests/src/cocotest/agnostic/primary_2.coco b/coconut/tests/src/cocotest/agnostic/primary_2.coco index 0150a89c..72ad4e95 100644 --- a/coconut/tests/src/cocotest/agnostic/primary_2.coco +++ b/coconut/tests/src/cocotest/agnostic/primary_2.coco @@ -487,6 +487,7 @@ def primary_test_2() -> bool: match (x=) in (x=13, y=13): assert False assert x == 12 + assert (x=1).__match_args__ == ('x',) # type: ignore with process_map.multiple_sequential_calls(): # type: ignore assert map((+), range(3), range(4)$[:-1], strict=True) |> list == [0, 2, 4] == process_map((+), range(3), range(4)$[:-1], strict=True) |> list # type: ignore