From 64c98f14c839d15f004a7c151990a0abb08df50a Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Thu, 19 Sep 2024 09:00:16 -0400 Subject: [PATCH 1/2] Use Hy 1 --- docs/conf.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 38522253..eebeaac7 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -16,7 +16,7 @@ copyright = '%s the authors' % time.strftime('%Y') html_title = f'Hyrule {hyrule.__version__} manual' -hy_version = 'v0.29.0' +hy_version = 'v1.0.0' exclude_patterns = ['_build'] diff --git a/setup.py b/setup.py index 9a5f994e..2d5d3a14 100644 --- a/setup.py +++ b/setup.py @@ -25,7 +25,7 @@ def run(self): # both setup_requires and install_requires # since we need to compile .hy files during setup requires = [ - 'hy' + 'hy >= 1' ] From 5a9431a330c1f39dca1efc411d5fc7bc9bdd6b98 Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Sat, 21 Sep 2024 17:45:37 -0400 Subject: [PATCH 2/2] Ensure `parse-fn-params` parses the whole input --- NEWS.rst | 7 ++++++- hyrule/macrotools.hy | 6 +++--- tests/test_macrotools.hy | 7 ++++++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/NEWS.rst b/NEWS.rst index 69d172eb..348b48aa 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -1,12 +1,17 @@ .. default-role:: code -Unreleased +0.7.0 (released 2024-09-22; uses Hy ≥ 1) ====================================================== New Features ------------------------------ * New macros `meth` and `ameth`. +Bug Fixes +------------------------------ +* `match-fn-params` now raises an error for syntactically invalid + parameter lists. + 0.6.0 (released 2024-05-20; uses Hy 0.29.*) ====================================================== diff --git a/hyrule/macrotools.hy b/hyrule/macrotools.hy index 8292c231..227b98f0 100644 --- a/hyrule/macrotools.hy +++ b/hyrule/macrotools.hy @@ -129,16 +129,16 @@ "A subroutine for `defmacro-kwargs` and `match-params`." (import funcparserlib.parser [maybe many] - hy.model-patterns [SYM FORM sym brackets pexpr]) + hy.model-patterns [SYM FORM sym brackets pexpr whole]) (setv msym (>> SYM hy.mangle)) (defn pvalue [root wanted] (>> (pexpr (+ (sym root) wanted)) (fn [x] (get x 0)))) (setv [ps p-rest p-kwargs] (.parse - (+ + (whole [ (many (| msym (brackets msym FORM))) (maybe (pvalue "unpack-iterable" msym)) - (maybe (pvalue "unpack-mapping" msym))) + (maybe (pvalue "unpack-mapping" msym))]) params)) (setv ps (dfor p ps diff --git a/tests/test_macrotools.hy b/tests/test_macrotools.hy index eb05daed..30afbba1 100644 --- a/tests/test_macrotools.hy +++ b/tests/test_macrotools.hy @@ -205,7 +205,12 @@ (with [(pytest.raises TypeError :match "^unpacking is not allowed in `args`$")] (f '[1 2 3 #* [1 2]])) (with [(pytest.raises TypeError :match "^unpacking is not allowed in `args`$")] - (f '[1 2 3 #** {"qq" 1 "xx" 2}]))) + (f '[1 2 3 #** {"qq" 1 "xx" 2}])) + + ; A syntactically invalid parameter list + (with [(pytest.raises hy.I.funcparserlib/parser.NoParseError)] + (match-fn-params [1] '[a 3])) + (assert (= (match-fn-params [1] '[a]) (dict :a 1)))) (defn test-slash-import []