malli icon indicating copy to clipboard operation
malli copied to clipboard

Arity error in function schema

Open respatialized opened this issue 3 years ago • 1 comments

Issue

A function schema produces an error due to overlapping arities when I attempt to use a seqex as the schema for one of the function's input arguments.

Reproducing the bug

Attempting to create the following schema throws an error.

(m/schema
 [:function
  [:=> [:cat [:schema [:* :int]]] :any]
  [:=> [:cat [:schema [:* :int]] :boolean] :any]])
{:type :malli.core/duplicate-arities,
    :message :malli.core/duplicate-arities,
    :data
    {:infos
     [{:min 0, :arity :varargs, :input [:cat [:schema [:* :int]]], :output :any}
      {:min 1,
       :arity :varargs,
       :input [:cat [:schema [:* :int]] :boolean],
       :output :any}]}}

Further information

This error occurs in spite of the fact that the input arities are independently both valid and produce the expected values when used as generators:

(mg/generate [:cat [:schema [:cat [:* :int]]] :boolean])
;; => ((-2 2096836 3803 45 -49393) false)
(mg/generate [:cat [:schema [:cat [:* :int]]]])
;; => ((-1709 -2289 -38 3962880 -8 -948 13075997 77734 -16118422 635358 2 -1 -1))

@ikitommi suggested that m/-regex-min-max might be contributing to the error:

Looks like :schema has a bug related to m/-regex-min-max :

(m/-regex-min-max
(m/schema
 [:cat [:schema [:* :int]]]))
; => {:min 0} 

Previously reported on the #malli channel on the Clojurians Slack.

respatialized avatar Dec 20 '21 15:12 respatialized