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

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

Open
sergey-latacora opened this issue Feb 12, 2022 · 0 comments

Comments

@sergey-latacora
Copy link

sergey-latacora commented Feb 12, 2022

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.

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

No branches or pull requests

2 participants