This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-01-07
Channels
- # announcements (2)
- # beginners (30)
- # calva (7)
- # cherry (15)
- # clerk (21)
- # clojure (1)
- # clojure-losangeles (12)
- # clojure-norway (1)
- # clojure-spec (3)
- # clojurescript (31)
- # conjure (2)
- # cursive (44)
- # datomic (13)
- # emacs (13)
- # honeysql (15)
- # hyperfiddle (7)
- # malli (2)
- # off-topic (17)
- # overtone (6)
- # reitit (7)
- # ring (58)
- # shadow-cljs (12)
- # squint (14)
- # tools-deps (14)
- # web-security (1)
- # xtdb (29)
hey. how can I depend on stabile versions of cherry from a deps project? Malli has:
{io.github.squint-cljs/cherry {:git/sha "24635085f3a268e624dee5f6b7ec049323a01173"}}
autoupdated to latest commit, but the malli tests fail with those:
{io.github.squint-cljs/cherry {:git/sha "21ec3e33d7cc5df88ba75bbb563522f843e846fd"}}
why isn't this CI step failing then? https://github.com/metosin/malli/actions/runs/7438587140/job/20237501990
btw, all-ns doesn't exist in CLJS: WARNING: Use of undeclared Var malli.registry/all-ns at line 67 /home/runner/work/malli/malli/src/malli/registry.cljc
I'd fix all the warnings here: https://github.com/metosin/malli/actions/runs/7438032106/job/20236337653#step:7:197 This is not the cause for cherry failing probably, but it's just not so clean
I'm debugging with cherry latest:
$ clj -A:cherry -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "RELEASE"}}}' -M -m cljs.main -re node
ClojureScript 1.11.121
cljs.user=> (require 'malli.cherry)
WARNING: Can't take value of macro cljs.core/ns-publics at line 67 /Users/borkdude/dev/malli/src/malli/registry.cljc
WARNING: Use of undeclared Var malli.registry/all-ns at line 67 /Users/borkdude/dev/malli/src/malli/registry.cljc
nil
cljs.user=> (require '[malli.core :as m])
nil
cljs.user=> (m/validate [:fn '(fn [x] (js/console.log x) x)] 1)
:compiled "(function (x) {\nconsole.log(x);\nreturn x\n})"
1
true
So what is weird that the function schema is compiled and the function is being called.
(testing "fn schemas"
(doseq [fn ['(fn [x] (js/console.log "fn schema" x (int? x) (< 10 x 18))
(and (int? x) (< 10 x 18)))
"(fn [x]
(js/console.log \"fn schema\" x (int? x) (< 10 x 18))
(and (int? x) (< 10 x 18)))"]]
(let [schema (m/schema [:fn {:description "number between 10 and 18"} fn])]
(js/console.log "pre fail")
(is (true? (m/validate schema 12)) (str "nooo: " (pr-str schema)))
(js/console.log "after fail")
output:
pre fail
fn schema 12 true true
FAIL in (validation-test) (/Users/borkdude/dev/malli/test/malli/core_test.cljc:813:13)
fn schemas
nooo: #object[malli.core.t_malli$core10071]
expected: (true? (m/validate schema 12))
actual: (not (true? false))
after fail
hm repro:
cljs.user=> (m/validate (m/schema [:fn {:description "dude"} "(fn [x] (js/console.log x (int? x) (< 10 x 18)) (and (int? x) (< 10 x 18)))"]) 12)
12 true true
false
ah got it, there is something wrong with a missing return:
cljs.user=> (m/validate (m/schema [:fn {:description "dude"} '(fn [x] (and (int? x) (< 10 x 18)))]) 12)
:compiled "(function (x) {\nlet and__8758__auto__1 = cljs.core.int_QMARK_.call(null, x);\nif (cljs.core.truth_.call(null, and__8758__auto__1)) {\n((10 < x) && (x < 18))} else {\nreturn and__8758__auto__1}\n})"
false