<< Back to previous view

[MATCH-52] Pattern Map's aren't working Created: 12/Feb/12  Updated: 28/Jul/13  Resolved: 14/Aug/12

Status: Closed
Project: core.match
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Defect Priority: Critical
Reporter: Jason Jackson Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: None

Attachments: Text File 0001-map-matching-always-checks-for-presence-of-key-even-.patch     Text File 0001-Map-matching-should-always-check-for-presence-of-key.patch     File patch    


Neither of these work as expected:

(match [ {:type :consumed :value 4}]
[({:uid uid :modifiers ms} :only [:uid :modifiers])] :a0)

(match [ {:type :consumed :value 4}]
[{:uid uid :modifiers ms} ] :a0)

Tried these versions:

Comment by Jason Jackson [ 12/Feb/12 11:33 PM ]

I tried to use :when to detect when key is not found. But this doesn't work either.
(match {:foo 3}
{:uid (uid :when #(not (nil? %)))} :a0)

Comment by David Nolen [ 14/Feb/12 4:31 PM ]

Looks good, but can you create the patch so that it contains your credentials as well as test cases? Thanks!

Comment by Jason Jackson [ 13/May/12 12:06 PM ]

added unit tests and attribution info.

Comment by Kevin Lynagh [ 13/Aug/12 11:18 PM ]

I've manually applied this patch to the latest master and verified that it fixes the issue.
Patch attached and also available on the Github:


EDIT: spoke too soon; I can't seem to upload the patch to JIRA as a commenter. Available here: https://github.com/lynaghk/core.match/compare/issue-52.patch

I've also added a commit on top to get ClojureScript support.
The implementation feels a bit gross to me (it inlines the clojure core.match val-at* function, basically) but a nicer solution isn't obvious to me given ClojureScript's macro/runtime divide.

Comment by Kevin Lynagh [ 14/Aug/12 9:05 PM ]

Updated Jason Jackson's patch with CLJS support.

Comment by David Nolen [ 14/Aug/12 9:11 PM ]

Fixed, http://github.com/clojure/core.match/commit/7f73cee3f78417f1fb59bcbb4a8cda52de22efbd

Generated at Fri Feb 15 17:06:30 CST 2019 using JIRA 4.4#649-r158309.