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

:? doesn't work properly in function schemas in cljs #1063

Open
simonacca opened this issue May 31, 2024 · 1 comment
Open

:? doesn't work properly in function schemas in cljs #1063

simonacca opened this issue May 31, 2024 · 1 comment

Comments

@simonacca
Copy link
Contributor

Hi there,
I encountered a discrepancy in the behavior of multi-arity schemas in clj vs cljs, seems like a bug.

In the following example, the spec is defined with the documented syntax for multi-arity functions. This fails both in clj and cljs, as expected, so far so good.

(defn myfn-a
  {:malli/schema [:function 
                  [:=> [:cat :int :int ] :keyword]
                  [:=> [:cat :int :int :string] :keyword]]}
  ([a b] :res1)
  ([a b c] :res2))

(myfn-a 1 2 3)

The following spec however fails with "invalid function arguments" in clj (expected behavior) and succeeds silently (that is, it doesn't throw any error) in cljs (this is surprising to me).

(defn myfn-b
  {:malli/schema [:=> [:cat :int [:? :int] :string] :keyword]}
  ([a b] :res3)
  ([a b c] :res4))
(myfn-b 1 2 3)
@frenchy64
Copy link
Collaborator

Reproduced here.

My initial assessment is that because m/-function-info returns :varargs for [:=> [:cat :int [:? :int] :string] :keyword], the cljs$core$IFn$_invoke$arity$variadic arity is wrapped instead of the cljs$core$IFn$_invoke$arity$ arity.

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

No branches or pull requests

2 participants