Cannot deny `fn*` without denying the `fn` macros

Open
#1,002 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
52/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
clojure
Domain
compilers

Research direction

Start by reproducing the reported expressions through sci/eval-string with :deny, comparing direct fn* use against fn, defn, letfn, bound-fn, loop*, and let*. Done means indirect forms continue to work while directly invoking a denied special form still raises the expected error.

Written by the indexing model from the issue text.

Description

version

0.10.49 and lower

platform

JVM

problem

We can't :deny fn* without denying the fn macros


(sci/eval-string "((fn* [a] a) 1)" {:deny ['fn*]}) ;=> clojure.lang.ExceptionInfo: fn* is not allowed! 
(sci/eval-string "((fn [a] a) 1)" {:deny ['fn*]})  ;=> clojure.lang.ExceptionInfo: fn* is not allowed!
(sci/eval-string "(defn f [a] a) (f a)" {:deny ['fn*]})  ;=> clojure.lang.ExceptionInfo: fn* is not allowed!
(sci/eval-string "(letfn [(f [a] a)] (f a))" {:deny ['fn*]})  ;=> clojure.lang.ExceptionInfo: fn* is not allowed!
(sci/eval-string "((bound-fn* (fn [a] a)) 1)" {:deny ['fn*]})  ;=> clojure.lang.ExceptionInfo: fn* is not allowed!
(sci/eval-string "((bound-fn [a] a) 1)" {:deny ['fn*]})  ;=> clojure.lang.ExceptionInfo: fn* is not allowed!

We see something similar when denying loop* and let*

 (sci/eval-string "(loop [i 10] (if (< i 0) :done (recur (dec i))))" {:deny ['loop*]})
clojure.lang.ExceptionInfo: loop* is not allowed! [at <repl>:1:1]
(sci/eval-string "(let [i 10] i)" {:deny ['let*]})
clojure.lang.ExceptionInfo: let* is not allowed! [at <repl>:1:1]

;; case is fine:
(sci/eval-string "(case 1 :ok)" {:deny ['case*]}) ;=> :ok

expected behavior

No error and the code would work like without the :deny since fn* is not called directly.

Dominant language
Clojure
Stars
1.4k
Forks
109
Avg merge
1m
Merged PRs (30d)
26

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from babashka/sci

All issues in babashka/sci

Similar issues

More Clojure issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.