Skip to content

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

Open
@simonacca

Description

@simonacca

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)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions