metosin / malli

High-performance data-driven data specification library for Clojure/Script.
Eclipse Public License 2.0
1.43k stars 204 forks source link

qualified keywords in :keys in mx/defn fails macro schema validator. #1028

Open jasonjckn opened 3 months ago

jasonjckn commented 3 months ago

The following code

(require '[malli.experimental :as m.x])
(m.x/defn foo [& {:keys [::opts]}] )

produces this error

  Show: Project-Only All 
  Hide: Clojure Java REPL Tooling Duplicates  (30 frames hidden)

1. Unhandled clojure.lang.ExceptionInfo
   -- Error in registering a Function Schema ---------------- NO_SOURCE_FILE:268 --

   Function Var:

     usb.auxiliary.if.datomic.transact/foo (:clj)

   Function Schema:

     [:=> [:cat [:altn [:map [:map [:usb.auxiliary.if.datomic.transact/opts {:optional true}]]] [:args [:*
   [:alt [:cat [:= :usb.auxiliary.if.datomic.transact/opts] :usb.auxiliary.if.datomic.transact/opts] [:cat
   :any :any]]]]]] :any]

   More information:

     https://cljdoc.org/d/metosin/malli/CURRENT/doc/function-schemas

   --------------------------------------------------------------------------------

   {:type :malli.core/register-function-schema,
    :data
    {:ns usb.auxiliary.if.datomic.transact,
     :name foo,
     :schema
     [:=>
      [:cat
       [:altn
        [:map [:map [:usb.auxiliary.if.datomic.transact/opts {:optional true}]]]
        [:args
         [:*
          [:alt
           [:cat [:= :usb.auxiliary.if.datomic.transact/opts] :usb.auxiliary.if.datomic.transact/opts]
           [:cat :any :any]]]]]]
      :any],
     :data nil,
     :key :clj,
     :exception #error {
    :cause "-- Schema Creation Error --------------------------------- NO_SOURCE_FILE:268 --\n\nInvalid Schema\n\n  :usb.auxiliary.if.datomic.transact/opts\n\nMore information:\n\n  https://cljdoc.org/d/metosin/malli/CURRENT\n\n--------------------------------------------------------------------------------\n"
    :data {:type :malli.core/invalid-schema, :data {:schema :usb.auxiliary.if.datomic.transact/opts, :form :usb.auxiliary.if.datomic.transact/opts}}
    :via
    [{:type clojure.lang.ExceptionInfo
      :message "-- Schema Creation Error --------------------------------- NO_SOURCE_FILE:268 --\n\nInvalid Schema\n\n  :usb.auxiliary.if.datomic.transact/opts\n\nMore information:\n\n  https://cljdoc.org/d/metosin/malli/CURRENT\n\n--------------------------------------------------------------------------------\n"
      :data {:type :malli.core/invalid-schema, :data {:schema :usb.auxiliary.if.datomic.transact/opts, :form :usb.auxiliary.if.datomic.transact/opts}}
      :at [malli.dev.pretty$thrower$fn__17467 invoke "pretty.cljc" 168]}]
    :trace
    [[malli.dev.pretty$thrower$fn__17467 invoke "pretty.cljc" 168]
     [malli.dev$_capture_fail_BANG_$fn__41146$_fail_BANG___41147 invoke "dev.clj" 19]
     [clojure.lang.AFn applyToHelper "AFn.java" 156]
     [clojure.lang.AFn applyTo "AFn.java" 144]
     [clojure.lang.AFunction$1 doInvoke "AFunction.java" 33]
     [clojure.lang.RestFn invoke "RestFn.java" 424]
     [malli.core$_lookup_BANG_ invokeStatic "core.cljc" 271]
     [malli.core$_lookup_BANG_ invoke "core.cljc" 267]
     [malli.core$schema invokeStatic "core.cljc" 2050]
     [malli.core$schema invoke "core.cljc" 2028]
     [malli.core$_parse_entry$_schema__9124 invoke "core.cljc" 418]
     [malli.core$_parse_entry$_parse_ref_vector2__9132 invoke "core.cljc" 428]
     [malli.core$_parse_entry invokeStatic "core.cljc" 453]
     [malli.core$_parse_entry invoke "core.cljc" 410]
     [malli.core$_eager_entry_parser invokeStatic "core.cljc" 484]
     [malli.core$_eager_entry_parser invoke "core.cljc" 461]
     [malli.core$_create_entry_parser invokeStatic "core.cljc" 498]
     [malli.core$_create_entry_parser invoke "core.cljc" 495]
     [malli.core$_map_schema$reify__9451 _into_schema "core.cljc" 969]
     [malli.core$into_schema invokeStatic "core.cljc" 1986]
     [malli.core$into_schema invoke "core.cljc" 1977]
     [malli.core$schema invokeStatic "core.cljc" 2047]
     [malli.core$schema invoke "core.cljc" 2028]
     [malli.core$_parse_entry$_schema__9124 invoke "core.cljc" 418]
     [malli.core$_parse_entry$_parse_entry_else2__9134 invoke "core.cljc" 432]
     [malli.core$_parse_entry invokeStatic "core.cljc" 454]
     [malli.core$_parse_entry invoke "core.cljc" 410]
     [malli.core$_eager_entry_parser invokeStatic "core.cljc" 484]
     [malli.core$_eager_entry_parser invoke "core.cljc" 461]
     [malli.core$_create_entry_parser invokeStatic "core.cljc" 498]
     [malli.core$_create_entry_parser invoke "core.cljc" 495]
     [malli.core$_sequence_entry_schema$reify__10002 _into_schema "core.cljc" 1926]
     [malli.core$into_schema invokeStatic "core.cljc" 1986]
     [malli.core$into_schema invoke "core.cljc" 1977]
     [malli.core$schema invokeStatic "core.cljc" 2047]
     [malli.core$schema invoke "core.cljc" 2028]
     [malli.core$_sequence_schema$reify__9986$fn__9987 invoke "core.cljc" 1879]
     [malli.impl.util$_vmap invokeStatic "util.cljc" 29]
NoahTheDuke commented 3 months ago

Is this legal clojure outside of mx/defn?

jasonjckn commented 3 months ago

@NoahTheDuke

yes

image

if maintainer(s) accepts the issue, i can probably send the MR, i'm guessing it's pretty trivial fix.