allow shadowing of prelude
This commit is contained in:
parent
7467bc8867
commit
98421a9215
|
@ -51,14 +51,12 @@
|
|||
(-> out j/encode string)
|
||||
)
|
||||
|
||||
# (comment
|
||||
(do
|
||||
(comment
|
||||
# (do
|
||||
# (def start (os/clock))
|
||||
(def source `
|
||||
let foo = :bar
|
||||
{
|
||||
let foo = :baz
|
||||
}
|
||||
let first = 1
|
||||
`)
|
||||
(def out (-> source
|
||||
ludus
|
||||
|
|
|
@ -102,6 +102,11 @@ Deferred until a later iteration of Ludus:
|
|||
(def node (get ctx name))
|
||||
(if node node (resolve-name (get ctx :^parent) name)))
|
||||
|
||||
(defn- resolve-name-in-script [ctx name]
|
||||
(when (ctx :^toplevel) (break nil))
|
||||
(def node (ctx name))
|
||||
(if node node (resolve-name-in-script (ctx :^parent) name)))
|
||||
|
||||
(defn- word [validator]
|
||||
(def ast (validator :ast))
|
||||
(def name (ast :data))
|
||||
|
@ -158,7 +163,7 @@ Deferred until a later iteration of Ludus:
|
|||
(def name (ast :data))
|
||||
(def ctx (validator :ctx))
|
||||
### XXX TODO: this resolution should ONLY be for userspace, NOT prelude
|
||||
(def resolved (resolve-name ctx name))
|
||||
(def resolved (resolve-name-in-script ctx name))
|
||||
(when resolved
|
||||
(def {:line line :input input} resolved)
|
||||
(array/push (validator :errors)
|
||||
|
@ -766,6 +771,7 @@ Deferred until a later iteration of Ludus:
|
|||
|
||||
(defn valid [ast &opt ctx]
|
||||
(default ctx @{})
|
||||
(set (ctx :^toplevel) true)
|
||||
(def validator (new-validator ast))
|
||||
(def base-ctx @{:^parent ctx})
|
||||
(set (validator :ctx) base-ctx)
|
||||
|
|
Loading…
Reference in New Issue
Block a user