noprompt / meander

Tools for transparent data transformation
MIT License
922 stars 55 forks source link

Bad behavior with or, unquote, and nested map patterns #170

Closed noprompt closed 3 years ago

noprompt commented 3 years ago
(ns scratch
  (:require [meander.epsilon :as m]))

(defn q? [m k]
  (m/find m
    (m/or {~k _}
          {:a {~k _}}
          {:b {~k _}})
    true

    _
    false))

;; RIGHT
(q? {:b :c} :b)
;; => true 

;; WRONG
(q? {:a {:b :c}} :b)
;; => false

;; WRONG
(q? {:b {:c :d}} :c)
;; => false