Fork me on GitHub
#cherry
<
2024-01-07
>
ikitommi19:01:44

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"}}

borkdude19:01:58

interesting

borkdude19:01:30

have you got a branch to show where it fails? I'll take a look tomorrow

borkdude19:01:50

Every commit on the main branch is supposed to be stable

ikitommi05:01:45

malli master, bb test-cherry

borkdude10:01:35

I see, you rolled back. I'll have a look

borkdude10:01:24

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

borkdude10:01:21

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

borkdude10:01:20

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

borkdude11:01:47

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

borkdude11:01:52

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

borkdude11:01:18

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

ikitommi15:01:31

awesome, thanks! I’ll check the all-ns .

👍 1