Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

m/from-ast does not work with symbols or unamespaced keywords #626

Closed
pfeodrippe opened this issue Jan 22, 2022 · 2 comments
Closed

m/from-ast does not work with symbols or unamespaced keywords #626

pfeodrippe opened this issue Jan 22, 2022 · 2 comments

Comments

@pfeodrippe
Copy link

pfeodrippe commented Jan 22, 2022

I'm having issues for BiggerThan4 and BiggerThan5 types below when trying to use m/from-ast.

(def BiggerThan3
  (m/schema
   (m/-simple-schema
    {:type :my/bigger-than-3
     :pred #(> % 3)})))

(def BiggerThan4
  (m/schema
   (m/-simple-schema
    {:type :my-bigger-than-4
     :pred #(> % 4)})))

(def BiggerThan5
  (m/schema
   (m/-simple-schema
    {:type 'my/bigger-than-5
     :pred #(> % 5)})))

(def options {:registry (malli.registry/composite-registry
                         (m/-registry)
                         {:my/bigger-than-3 BiggerThan3
                          :my-bigger-than-4 BiggerThan4
                          'my/bigger-than-5 BiggerThan5})})

;; This works fine.
(-> (m/ast :my/bigger-than-3 options)
    (m/from-ast options))

#_(-> (m/ast :my-bigger-than-4 options)
      (m/from-ast options))

#_(-> (m/ast 'my/bigger-than-5 options)
      (m/from-ast options))

They error with

1. Unhandled java.lang.AbstractMethodError
   malli/core/AST._from_ast(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

                 core.cljc: 2182  malli.core$from_ast/invokeStatic
                 core.cljc: 2171  malli.core$from_ast/invoke
                      REPL:  721  worker.invoice.sqs-test/eval42056
                      REPL:  720  worker.invoice.sqs-test/eval42056
             Compiler.java: 7181  clojure.lang.Compiler/eval
             Compiler.java: 7136  clojure.lang.Compiler/eval
                  core.clj: 3202  clojure.core/eval
                  core.clj: 3198  clojure.core/eval
    interruptible_eval.clj:   87  nrepl.middleware.interruptible-eval/evaluate/fn/fn
                  AFn.java:  152  clojure.lang.AFn/applyToHelper
                  AFn.java:  144  clojure.lang.AFn/applyTo
                  core.clj:  667  clojure.core/apply
                  core.clj: 1977  clojure.core/with-bindings*
                  core.clj: 1977  clojure.core/with-bindings*
               RestFn.java:  425  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   87  nrepl.middleware.interruptible-eval/evaluate/fn
                  main.clj:  437  clojure.main/repl/read-eval-print/fn
                  main.clj:  437  clojure.main/repl/read-eval-print
                  main.clj:  458  clojure.main/repl/fn
                  main.clj:  458  clojure.main/repl
                  main.clj:  368  clojure.main/repl
               RestFn.java: 1523  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   84  nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:   56  nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:  152  nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
                  AFn.java:   22  clojure.lang.AFn/run
               session.clj:  218  nrepl.middleware.session/session-exec/main-loop/fn
               session.clj:  217  nrepl.middleware.session/session-exec/main-loop
                  AFn.java:   22  clojure.lang.AFn/run
               Thread.java:  823  java.lang.Thread/run

Let me know if this is intentional and we should avoid using other than a namespaced keywords in our registries o/

pfeodrippe pushed a commit to pfeodrippe/pitoco that referenced this issue Jan 22, 2022
ikitommi added a commit that referenced this issue Jan 23, 2022
@ikitommi
Copy link
Member

Not intentional, there was a bug in m/from-ast, fixed now.

@pfeodrippe
Copy link
Author

Not intentional, there was a bug in m/from-ast, fixed now.

Thanks o/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants