partially applied functions don't kill validation
This commit is contained in:
parent
6bf4dde487
commit
e5917c6284
|
@ -338,14 +338,15 @@ Deferred until a later iteration of Ludus:
|
|||
|
||||
(defn- check-arity [validator]
|
||||
(def ast (validator :ast))
|
||||
(when (ast :partial) (break validator))
|
||||
# (when (ast :partial) (break validator))
|
||||
(def ctx (validator :ctx))
|
||||
(def data (ast :data))
|
||||
(def fn-word (first data))
|
||||
(def the-fn (resolve-name ctx (fn-word :data)))
|
||||
(when (not the-fn) (break validator))
|
||||
(when (= :function (type the-fn)) (break validator))
|
||||
(when (= :cfunction (type the-fn)) (break validator))
|
||||
(when (= :cfunction (type the-fn) (break validator)))
|
||||
(when (not= :fn (the-fn :type)) (break validator))
|
||||
(print "fn name: " (the-fn :name))
|
||||
(def arities (the-fn :arities))
|
||||
(print "arities: ")
|
||||
|
@ -353,6 +354,7 @@ Deferred until a later iteration of Ludus:
|
|||
(def args (get data 1))
|
||||
(def num-args (length (args :data)))
|
||||
(print "called with #args " num-args)
|
||||
(pp (get (validator :ctx) "bar"))
|
||||
(when (has-key? arities num-args) (break validator))
|
||||
(def rest-arities (keys (arities :rest)))
|
||||
(when (empty? rest-arities)
|
||||
|
@ -629,17 +631,20 @@ Deferred until a later iteration of Ludus:
|
|||
(set (validator :ctx) base-ctx)
|
||||
(validate validator))
|
||||
|
||||
(defn foo [] :foo)
|
||||
(def base {
|
||||
"foo" foo
|
||||
})
|
||||
(import ./base :as b)
|
||||
|
||||
(do
|
||||
# (comment
|
||||
(def source `
|
||||
foo ()
|
||||
fn foobar {
|
||||
(:foo, :bar) -> true
|
||||
(_, _) -> false
|
||||
}
|
||||
let bar = foobar (:foo, _)
|
||||
bar (:bar, 2)
|
||||
add ()
|
||||
`)
|
||||
(def scanned (s/scan source))
|
||||
(def parsed (p/parse scanned))
|
||||
(valid parsed base)
|
||||
(valid parsed b/ctx)
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue
Block a user