core.match

Bug in seq pattern matching

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

(let [l '(1 2 3)]
    (match [l]
      [([a & [b & [c d]]] :seq)] :a0
      :else :a1))

Matches when it shouldn't.

Activity

David Nolen made changes -
Field Original Value New Value
Priority Major [ 3 ] Critical [ 2 ]
Hide
Greg Chapman added a comment - - edited

Another example of (I think) the same issue:

user=> (let [x ()] (match [x] [([h & t] :seq)] [h t] [_] :a1))
[nil ()]

Perhaps SeqPattern's IPatternCompile should call seq in order to filter empty seqs? (e.g.:

(to-source* [this ocr]
`(and (or (seq? ~ocr) (sequential? ~ocr)) (seq ~ocr)))

Show
Greg Chapman added a comment - - edited Another example of (I think) the same issue: user=> (let [x ()] (match [x] [([h & t] :seq)] [h t] [_] :a1)) [nil ()] Perhaps SeqPattern's IPatternCompile should call seq in order to filter empty seqs? (e.g.: (to-source* [this ocr] `(and (or (seq? ~ocr) (sequential? ~ocr)) (seq ~ocr)))
David Nolen made changes -
Status Open [ 1 ] In Progress [ 3 ]
David Nolen made changes -
Resolution Completed [ 1 ]
Status In Progress [ 3 ] Resolved [ 5 ]
David Nolen made changes -
Status Resolved [ 5 ] Closed [ 6 ]

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: