fix random(dict) bug

This commit is contained in:
Scott Richmond 2024-06-07 16:45:31 -04:00
parent 533a40bd45
commit 9db10edd5c
2 changed files with 5 additions and 8 deletions

View File

@ -918,7 +918,7 @@ fn random {
}
(d as :dict) -> {
let key = do d > keys > random
get (d, key)
get (key, d)
}
}

View File

@ -21,19 +21,19 @@
(def out @{:errors errors :draw draw :result result :console console})
(def scanned (s/scan source))
(when (any? (scanned :errors))
(set (out :errors) (scanned :errors))
# (set (out :errors) (scanned :errors))
(each err (scanned :errors)
(e/scan-error err))
(break (-> out j/encode string)))
(def parsed (p/parse scanned))
(when (any? (parsed :errors))
(set (out :errors) (parsed :errors))
# (set (out :errors) (parsed :errors))
(each err (parsed :errors)
(e/parse-error err))
(break (-> out j/encode string)))
(def validated (v/valid parsed ctx))
(when (any? (validated :errors))
(set (out :errors) (validated :errors))
# (set (out :errors) (validated :errors))
(each err (validated :errors)
(e/validation-error err))
(break out))
@ -42,7 +42,7 @@
(set result (i/interpret (parsed :ast) ctx))
([err]
(e/runtime-error err)
(set (out :errors) [err])
# (set (out :errors) [err])
(break (-> out j/encode string))))
(setdyn :out stdout)
(set (out :result) (b/show result))
@ -53,7 +53,4 @@
(set (out :draw) (post :draw))
(-> out j/encode string))
(-> (ludus `
random (1, 3)
`) j/decode)