From 83b90b423775220c2448513b11036b2a65ad17c7 Mon Sep 17 00:00:00 2001 From: Geoffrey Gaillard Date: Thu, 1 Sep 2022 15:46:05 +0200 Subject: [PATCH] Fix variadic function arity missing `&` after emission --- src/hyperfiddle/rcf/analyzer.clj | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/hyperfiddle/rcf/analyzer.clj b/src/hyperfiddle/rcf/analyzer.clj index 8254b59..0a9d45a 100644 --- a/src/hyperfiddle/rcf/analyzer.clj +++ b/src/hyperfiddle/rcf/analyzer.clj @@ -580,7 +580,10 @@ (case (:local ast) :catch (:form ast) (:let :letfn) [(:name ast) (emit (:init ast))] - (:fn :arg) (:name ast))) + :fn (:name ast) + :arg (if (:variadic? ast) + ['& (:name ast)] + [(:name ast)]))) (defmethod -emit :quote [ast] (:form ast)) @@ -607,7 +610,7 @@ `(~'fn* ~@methods)))) (defmethod -emit :fn-method [ast] - (list (mapv emit (:params ast)) (emit (:body ast)))) + (list (vec (mapcat emit (:params ast))) (emit (:body ast)))) (defmethod -emit :letfn [ast] (list 'letfn* (vec (mapcat identity (mapv emit (:bindings ast)))) (emit (:body ast))))