core.match

Pattern Map's aren't working

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

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:
"0.2.0-alpha10-SNAPSHOT"
"0.2.0-alpha9"

Activity

Hide
Jason Jackson added a comment -

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)

Show
Jason Jackson added a comment - 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)
Jason Jackson made changes -
Field Original Value New Value
Attachment patch [ 10906 ]
Hide
David Nolen added a comment -

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

Show
David Nolen added a comment - Looks good, but can you create the patch so that it contains your credentials as well as test cases? Thanks!
Hide
Jason Jackson added a comment -

added unit tests and attribution info.

Show
Jason Jackson added a comment - added unit tests and attribution info.
Jason Jackson made changes -
Hide
Kevin Lynagh added a comment - - edited

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:

https://github.com/lynaghk/core.match/tree/issue-52

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.

Show
Kevin Lynagh added a comment - - edited 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: https://github.com/lynaghk/core.match/tree/issue-52 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.
Hide
Kevin Lynagh added a comment -

Updated Jason Jackson's patch with CLJS support.

Show
Kevin Lynagh added a comment - Updated Jason Jackson's patch with CLJS support.
Kevin Lynagh made changes -
David Nolen made changes -
Resolution Completed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]
David Nolen made changes -
Status Resolved [ 5 ] Closed [ 6 ]

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: