From a2b08f721c28b3b56a802031bc35df6a68b219d8 Mon Sep 17 00:00:00 2001 From: Andrey Orst Date: Thu, 31 Dec 2020 09:44:57 +0300 Subject: fix(macros): fix bug in try, add tests --- cljlib-macros.fnl | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'cljlib-macros.fnl') diff --git a/cljlib-macros.fnl b/cljlib-macros.fnl index 26c80d7..19b0107 100644 --- a/cljlib-macros.fnl +++ b/cljlib-macros.fnl @@ -1055,23 +1055,20 @@ clauses when we push body epression." (add-to-try finally catches try form)) (add-to-try finally catches try form))) `(match (pcall ,try) - (true res#) (do ,(. finally 1) res#) + (true _#) (do ,(. finally 1) _#) ,(make-catch-clauses catches finally)))) (attach-meta try {:fnl/arglist [:body* :catch-clause* :finally-clause?] :fnl/docstring "General purpose try/catch/finally macro. - -(try expression* catch-clause* finally-clause?) - Wraps its body in `pcall` and checks the return value with `match` macro. -Catch-clause is written either as (catch symbol body*), thus acting as +Catch clause is written either as (catch symbol body*), thus acting as catch-all, or (catch value body*) for catching specific errors. It is possible to have several `catch` clauses. If no `catch` clauses specified, an implicit catch-all clause is created. -Finally-clause is optional, and written as (finally body*). If +Finally clause is optional, and written as (finally body*). If present, it must be the last clause in the `try` form, and the only `finally` clause. Note that `finally` clause is for side effects only, and runs either after succesful run of `try` body, or after any -- cgit v1.2.3