Skip to content

"N or More" operator matches on empty list in m/search when N is nonzero #228

Open
@sergey-latacora

Description

When using the n or more operator to match a pattern in a vec with a preceding any (_) operator; the n-or-more operator will match empty lists in m/search. This behavior is different from from m/match, which will not match on empty lists.

Code snippet for reproducing:

(comment
  (require '[meander.epsilon :as m])
  (m/match
    []
    [_ ..2] :matched-two-or-more
    _ :didnt-mach)
  ;; => :didnt-mach ;; this is expected, there are no items in the input vec
  (m/search
    []
    [_ ..2] :matched-two-or-more)
  ;; => (:matched-two-or-more) ;; the vec is empty, so this should be nil, but the expression returns :matched-two-or-more
  )

See brief discussion in clojurians slack for a bit more context.

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions