recur detection logic is too naive

Description

The following explodes because of the presence of recur:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 (defn rec [expr] (match expr [:global] 'GLOBAL [:constant x] x [:variable x] x [:lazy-variable x] `(deref ~x) [:if test if-true if-false] `(if ~(rec test) ~(rec if-true) ~(rec if-false)) [:delist list index] `(get ~(rec list) ~(rec index)) [:depair pair key] `(get ~(rec pair) ~(match key :first 0 :second 1)) [:list elements] (map rec elements) [:fold-recur index-arg list-sym] `(recur (+ 1 ~index-arg) (rest ~list-sym)) [:zip left right] `(map vector ~(rec left) ~(rec right)) [:filter list arg body] `(filter (fn [~arg] ~(rec body) ~(rec list))) [:len list] `(count ~(rec list)) [:pair first second] [(rec first) (rec second)] [:block arg body] `(fn [~arg] ~(rec body)) [:app f arg] `(~(rec f) ~(rec arg)) [:query e annotations] `(QUERY ~(rec e) ~annotations) [:lookup key] `(LOOKUP ~key) [:let name value expr] `(let [~name ~value] expr) ; ... about 15 more ))

Environment

None

Status

Assignee

David Nolen

Reporter

David Nolen

Labels

None

Approval

None

Patch

None

Priority

Critical