matchure icon indicating copy to clipboard operation
matchure copied to clipboard

Blowing heap on if-match on or expression

Open tgk opened this issue 14 years ago • 1 comments

When trying to construct a function for balancing a red-black tree we ran into a problem when constructing a set of four different patterns for matching a tree. The heap is blown when trying to compile the function below.

(defn balance [tree]
  (if-match [(or [:black [:red [:red ?a ?x ?b] ?y ?c] ?z ?d]
         [:black [:red ?a ?x [:red ?b ?y ?c]] ?z ?d]
         [:black ?a ?x [:red [:red ?b ?y ?c] ?z ?d]] 
         [:black ?a ?x [:red ?b ?y [:red ?c ?z ?d]]]) tree]
        [:red [:black a x b] y [:black c z d]]
        tree))

For a complete example, please see this gist

tgk avatar Jan 17 '11 20:01 tgk

Ouch. Thanks for the bug report. I'll look into this as soon as I can.

dcolthorp avatar Jan 17 '11 21:01 dcolthorp