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

オープン
#1,002 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
52/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
静か
技術スタック
clojure
領域
compilers

調査の方向性

まず、:deny を指定した sci/eval-string を使って報告された式を再現し、fn* の直接使用と fn、defn、letfn、bound-fn、loop*、let* を比較します。間接的な形式は引き続き動作し、拒否された special form を直接呼び出した場合には期待されるエラーが引き続き発生すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Clojure
スター
1.4k
フォーク
109
平均マージ
1分
マージ済み PR(30日)
26

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

babashka/sci のほかの issue

babashka/sci の issue をすべて見る

似ている issue

Clojure の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。