cherry

ikitommi 2024-01-07T19:21:44.691589Z

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

borkdude 2024-01-08T09:59:40.840709Z

why isn't this CI step failing then? https://github.com/metosin/malli/actions/runs/7438587140/job/20237501990

borkdude 2024-01-08T10:00:35.274369Z

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

borkdude 2024-01-08T10:01:24.698239Z

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

borkdude 2024-01-08T10:02:21.730239Z

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

borkdude 2024-01-08T10:53:20.670539Z

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

borkdude 2024-01-08T11:01:47.529639Z

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

borkdude 2024-01-08T11:05:52.905259Z

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

borkdude 2024-01-08T11:07:18.802859Z

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

borkdude 2024-01-08T11:22:38.934419Z

@ikitommi Fixed: https://github.com/metosin/malli/pull/991

ikitommi 2024-01-08T15:05:31.097099Z

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

👍 1
borkdude 2024-01-07T19:29:58.754669Z

interesting

borkdude 2024-01-07T19:30:30.949649Z

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

borkdude 2024-01-07T19:36:50.567369Z

Every commit on the main branch is supposed to be stable

ikitommi 2024-01-08T05:56:45.065869Z

malli master, bb test-cherry