[MATCH-52] Pattern Map's aren't working Created: 12/Feb/12 Updated: 14/Aug/12 Resolved: 14/Aug/12 |
|
| Status: | Resolved |
| 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: |
|
| Description |
|
Neither of these work as expected: (match [ {:type :consumed :value 4}] (match [ {:type :consumed :value 4}] Tried these versions: |
| Comments |
| 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. |
| 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. 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. |
| 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 |
[MATCH-6] Nested rest pattern in vector patterns cause infinite loop Created: 04/Sep/11 Updated: 26/Sep/11 Resolved: 26/Sep/11 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Major |
| Reporter: | David Nolen | Assignee: | David Nolen |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Nested rest patterns combined w/ vector patterns cause an infinite loop. |
| Comments |
| Comment by David Nolen [ 26/Sep/11 5:59 AM ] |
[MATCH-10] map pattern keys should be allowed to be heterogenous types Created: 04/Sep/11 Updated: 27/Oct/11 Resolved: 27/Oct/11 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Major |
| Reporter: | David Nolen | Assignee: | David Nolen |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Right now they fail since heterogenous keys can't be sorted. |
| Comments |
| Comment by David Nolen [ 27/Oct/11 11:39 PM ] |
|
Fixed, https://github.com/clojure/core.match/commit/3a2e5598b6fc7ad52caa0869802d0ed80ba54124 |
[MATCH-12] Migrate to Maven Created: 04/Sep/11 Updated: 23/Sep/11 Resolved: 23/Sep/11 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major |
| Reporter: | Ambrose Bonnaire-Sergeant | Assignee: | David Nolen |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Waiting On: | David Nolen |
| Description |
|
AFAIK we need to migrate to Maven for Contrib projects. I used core.logic as a template and it seems to have been successful. Anything missing? https://github.com/clojure/core.match/commit/5146212edecbd8d765028e165352d20005b44cc3 |
| Comments |
| Comment by David Nolen [ 05/Sep/11 10:40 AM ] |
|
This looks OK to me, do all tests pass? |
| Comment by Ambrose Bonnaire-Sergeant [ 05/Sep/11 10:56 AM ] |
|
Yep, all tests pass. |
[MATCH-13] Invalid method Code length when generating red black tree matcher Created: 05/Sep/11 Updated: 28/Sep/11 Resolved: 28/Sep/11 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Major |
| Reporter: | Thomas Greve Kristensen | Assignee: | David Nolen |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
lein --version |
||
| Description |
|
The issue is the same as stated on Here is a copy of the text from the issue above: After having forked the latest version on branch and compiling I attempted to execute the infamous red-black tree rebalancing code. (let [node nil] error: java.lang.ClassFormatError: Invalid method Code length 78596 in class file redblack/core$eval3306 (core.clj:10) |
| Comments |
| Comment by David Nolen [ 05/Sep/11 3:43 PM ] |
|
Do you encounter this error at the REPL? |
| Comment by Thomas Greve Kristensen [ 05/Sep/11 11:26 PM ] |
|
Sort of - it is encountered when connecting to the REPL using swank form emacs. |
| Comment by David Nolen [ 05/Sep/11 11:43 PM ] |
|
Can you elaborate the exact steps? What OS? I'm interested in knowing the details since I haven't run into it myself - solving http://dev.clojure.org/jira/browse/MATCH-1 should address this problem. |
| Comment by Thomas Greve Kristensen [ 06/Sep/11 2:21 AM ] |
|
I have executed all my tests on a mac os x lion 10.7.1. I've just added my (failing) code to github, it can be found here: The steps are as follows: Sorry for the very brief description, but I'm at work... |
| Comment by Thomas Greve Kristensen [ 06/Sep/11 12:33 PM ] |
|
Here's a bit longer description: First, I cloned clojure.core.match.core and installed it using I have added a :main description to the project above. To make it fail I can simply use |
| Comment by Thomas Greve Kristensen [ 07/Sep/11 1:23 PM ] |
|
I have also tried using 1.3.0-master-SNAPSHOT of clojure but with no luck. Which version of java are you using? |
| Comment by Thomas Greve Kristensen [ 07/Sep/11 1:23 PM ] |
|
I have also tried using 1.3.0-master-SNAPSHOT of clojure but with no luck. Which version of java are you using? |
| Comment by David Nolen [ 07/Sep/11 1:52 PM ] |
|
Sorry been a bit swamped so I haven't had a chance to go through your exact steps (I'm sure I'll get the same error). Again I'm pretty confident I know why the red black tree pattern generates so much code. Adding backtracking will be a significant code size optimization. |
| Comment by David Nolen [ 26/Sep/11 6:59 AM ] |
|
See |
| Comment by David Nolen [ 28/Sep/11 10:47 PM ] |
|
Fixed now in master. |
[MATCH-1] Investigate non-overlapping pattern optimization via pre-allocated exception for backtracking Created: 04/Sep/11 Updated: 28/Sep/11 Resolved: 28/Sep/11 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major |
| Reporter: | David Nolen | Assignee: | David Nolen |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
The red black tree balance pattern mentioned by tgk generates enough code that the JVM will not inline it. Maranget's algorithm basically implements backtracking by passing along wildcard matches with actual matches. For non-overlapping patterns like the red black tree balance pattern this means exponential code size. For such patterns where none of the actions involve recur we could implement backtracking with a pre-allocated exception. http://blogs.oracle.com/jrose/entry/longjumps_considered_inexpensive |
| Comments |
| Comment by David Nolen [ 28/Sep/11 10:46 PM ] |
|
Fixed now in master. |
[MATCH-14] Vector Pattern bug when patterns not all of the same length Created: 13/Sep/11 Updated: 26/Sep/11 Resolved: 26/Sep/11 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Major |
| Reporter: | David Nolen | Assignee: | David Nolen |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
(let [v [[1 2]]] Throws out of bounds exception error |
| Comments |
| Comment by David Nolen [ 26/Sep/11 5:57 AM ] |
|
Fixed, https://github.com/clojure/core.match/commit/2f5d82bfb6031325114b9a5aaad975fb60dd7bd3 |
[MATCH-15] Binding issue Created: 22/Sep/11 Updated: 25/Sep/11 Resolved: 25/Sep/11 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Major |
| Reporter: | Ronen Narkis | Assignee: | David Nolen |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Latest HEAD version of match while compile my project https://github.com/narkisr/gitolite-webui/tree/match-fix |
||
| Description |
|
The binding in the match macro used in gitolite-webui.notification 41: (defn email-request [req] Trying to create jar results with: (match-fix)⚡ % lein uberjar ~/CodeProjects/gitolite-webui Trying to use an else clause: (defn email-request [req] Exception in thread "main" java.lang.RuntimeException: java.lang.IllegalArgumentException: No method in multimethod 'to-source' for dispatch value: class clojure.core.match.core.WildcardPattern (notification.clj:42) |
| Comments |
| Comment by David Nolen [ 22/Sep/11 6:50 PM ] |
|
Thanks! However, this is too much context. Please add an isolated case. This limits the moving parts as well as make it easy to add a new test case to handle your issue. |
| Comment by Ronen Narkis [ 23/Sep/11 3:59 PM ] |
|
Hey David, iv created a single file project that reproduces this: https://github.com/narkisr/MATCH_15 The single function in there is: (defn email-request [req] Running lein uberjar results with the same error. |
| Comment by David Nolen [ 25/Sep/11 7:53 PM ] |
|
Turns out this only affected AOT code. We were doing some dynamic things that did not play well w/ AOT. Fixed in master, https://github.com/clojure/core.match/commit/64eb9d4ff8774c3f228cfa8958043a65c083ec86 |
[MATCH-16] Empty Vector Patterns Fail to Match Created: 25/Sep/11 Updated: 25/Sep/11 Resolved: 25/Sep/11 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Major |
| Reporter: | Ambrose Bonnaire-Sergeant | Assignee: | David Nolen |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
(match [[]] Macro-expand'd: (let* Clearly this test is the issue: (clojure.core/= (clojure.core/count ocr-4856) 1)) |
| Comments |
| Comment by Ambrose Bonnaire-Sergeant [ 25/Sep/11 5:15 AM ] |
|
Bah, I'll try again: (match [[]]
[[]] "asdf")
#<RuntimeException java.lang.RuntimeException: java.lang.Exception: No match found. Followed 0 branches. Breadcrumbs: []>
(let*
[ocr-4856 []]
(clojure.core/cond
(clojure.core/and
(clojure.core/instance? clojure.lang.IPersistentVector ocr-4856)
(clojure.core/= (clojure.core/count ocr-4856) 1)) (clojure.core/let
[ocr-4856_0__4857
(clojure.core/nth
ocr-4856
0)]
(clojure.core/cond
(clojure.core/=
ocr-4856_0__4857
nil)
"asdf"
:else
(throw
(java.lang.Exception.
(clojure.core/str
"No match found. "
"Followed "
1
" branches."
" Breadcrumbs: "
'[(clojure.core/and
(clojure.core/instance?
clojure.lang.IPersistentVector
ocr-4856)
(clojure.core/=
(clojure.core/count
ocr-4856)
1))])))))
:else (throw
(java.lang.Exception.
(clojure.core/str
"No match found. "
"Followed "
0
" branches."
" Breadcrumbs: "
'[])))))
|
| Comment by David Nolen [ 25/Sep/11 5:53 PM ] |
|
Fixed, https://github.com/clojure/core.match/commit/9ba924ddd4e8cf9f08d44f2362bf04add1b69ae1 |
[MATCH-11] The order of pattern rows should be preserved Created: 04/Sep/11 Updated: 25/Sep/11 Resolved: 25/Sep/11 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Major |
| Reporter: | David Nolen | Assignee: | David Nolen |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Sometimes pattern rows are not preserved in the user defind order. Fix this and create the tests to show that this property is preserved. |
| Comments |
| Comment by David Nolen [ 25/Sep/11 8:50 PM ] |
|
Fixed, https://github.com/clojure/core.match/commit/5e2762fbca6179b3b19505d7603fc6a37108dba1 No tests. The rule is never reorder - always return 1. |
[MATCH-18] IndexOutOfBound exception using '&' in vector matching. Created: 28/Sep/11 Updated: 28/Sep/11 Resolved: 28/Sep/11 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Major |
| Reporter: | Nikita Beloglazov | Assignee: | David Nolen |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Following sample causes IndexOutOfBound exception. (match [[:pow :x 2]] Result: IndexOutOfBound But if we delete '&' everything works fine: (match [[:pow :x 2]] Result: 0 |
| Comments |
| Comment by David Nolen [ 28/Sep/11 8:23 PM ] |
|
Fixed, https://github.com/clojure/core.match/commit/e0677eec1dac387e369886a72c19f75262cecd68 |
[MATCH-17] first-column-chosen-case Infinite Loop at Compilation Created: 25/Sep/11 Updated: 26/Sep/11 Resolved: 26/Sep/11 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Major |
| Reporter: | Ambrose Bonnaire-Sergeant | Assignee: | David Nolen |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
See: https://gist.github.com/1241625 |
| Comments |
| Comment by David Nolen [ 26/Sep/11 5:48 AM ] |
|
Fixed, https://github.com/clojure/core.match/commit/1b01e7fc6634e081f6a96db41eb65c91b95b8161 |
[MATCH-21] Head-Tail Pattern Matching Fails for Lists Created: 30/Sep/11 Updated: 02/Oct/11 Resolved: 02/Oct/11 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Major |
| Reporter: | Ambrose Bonnaire-Sergeant | Assignee: | David Nolen |
| Resolution: | Declined | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Head-tail pattern matching only seems to work with vectors. Commit: https://github.com/clojure/core.match/commit/9f4919d855be09a1b32f9e5563ac1c3f5bace642 The following code falls through. (macroexpand appended) (let [x '(1 2 3)]
(match [x]
[[a & as]] :a))
(try (clojure.core/cond (clojure.core/instance? clojure.lang.IPersistentVector x) (try (clojure.core/let [x_left__3201 (clojure.core/subvec x 0 1)] (clojure.core/cond (clojure.core/and (clojure.core/instance? clojure.lang.IPersistentVector x_left__3201) (clojure.core/= (clojure.core/count x_left__3201) 1)) (clojure.core/let [a (clojure.core/nth x_left__3201 0) as (clojure.core/subvec x 1)] :a) :else (throw clojure.core.match.core/backtrack))) (catch java.lang.Exception e__2436__auto__ (throw clojure.core.match.core/backtrack))) :else (throw clojure.core.match.core/backtrack)) (catch java.lang.Exception e__2437__auto__ (throw clojure.core.match.core/backtrack))) |
| Comments |
| Comment by David Nolen [ 02/Oct/11 11:35 AM ] |
|
This is the expected behavior. If you want to match seqs you have to use the seq pattern syntax. |
[MATCH-22] boolean expression fails Created: 01/Oct/11 Updated: 02/Oct/11 Resolved: 02/Oct/11 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Major |
| Reporter: | David Nolen | Assignee: | David Nolen |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
(match [false] [false] true) throws an error. I thought I handled this case earlier, but seems like I missed something. |
| Comments |
| Comment by David Nolen [ 02/Oct/11 11:32 AM ] |
|
Fixed, https://github.com/clojure/core.match/commit/66a36260eb77c1920f9db011cdb612d4797665a7 |
[MATCH-20] Doesn't match 'head & tail' in vector matching. Created: 29/Sep/11 Updated: 02/Oct/11 Resolved: 02/Oct/11 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Major |
| Reporter: | Nikita Beloglazov | Assignee: | David Nolen |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Following code: (match [[:plus 1 2 3]] Returns 2, but must return 1. If we delete first clause it works: (match [[:plus 1 2 3]] Returns 1. |
| Comments |
| Comment by Nikita Beloglazov [ 01/Oct/11 1:11 PM ] |
|
Also works with [:plus 1 2] - vector size is now 3, was 4: (match [[:plus 1 2]] [[:pow arg pow]] 0 [[:plus & args]] 1 :else 2) => 1 |
| Comment by David Nolen [ 01/Oct/11 1:13 PM ] |
|
I have a pretty good idea what's wrong here as well as the fix. Hope to get this resolved in the next couple of days. |
| Comment by David Nolen [ 02/Oct/11 12:25 PM ] |
|
Fixed, https://github.com/clojure/core.match/commit/02f2ab62cba3d1017c2590b04946cb2c92190635 |
[MATCH-19] Analyze action bodies for the presence of recur, if recur is present do not use backtracking Created: 29/Sep/11 Updated: 02/Oct/11 Resolved: 02/Oct/11 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Enhancement | Priority: | Major |
| Reporter: | David Nolen | Assignee: | David Nolen |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
A post about matchure on the ML reminded about my original line of thinking. We should not use the backtracking solution if we detect the presence of recur in any of the action bodies. If it is present we should use the old compilation mechanism. |
| Comments |
| Comment by David Nolen [ 02/Oct/11 12:56 PM ] |
|
Fixed, https://github.com/clojure/core.match/commit/af4ca0425daee7dd7421716f6a151d2dda988a9a |
[MATCH-23] map pattern order bug Created: 03/Oct/11 Updated: 05/Oct/11 Resolved: 05/Oct/11 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Major |
| Reporter: | David Nolen | Assignee: | David Nolen |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
(let [x {:a 1 :b 2 :c 10 :d 30}] returns :a1 instead of :a-1 |
| Comments |
| Comment by David Nolen [ 05/Oct/11 9:39 PM ] |
|
Fixed, https://github.com/clojure/core.match/commit/61e05362872d7f336e0c12c42765806a9e5b8fc4 |
[MATCH-25] Map pattern :only case still not right Created: 05/Oct/11 Updated: 06/Oct/11 Resolved: 06/Oct/11 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Major |
| Reporter: | David Nolen | Assignee: | David Nolen |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Description |
(let [m {:a 1 :b 2}]
(match [m]
[({:a 1} :only [:a])] :a0
:else :a1))
We get :a0 instead of :a1 |
| Comments |
| Comment by David Nolen [ 06/Oct/11 8:28 PM ] |
|
Fixed, https://github.com/clojure/core.match/commit/3407090009b447b594a7c361c8891f9b6e8f72bb |
[MATCH-26] Bug in the way that constructor set for a column is computed Created: 05/Oct/11 Updated: 09/Oct/11 Resolved: 09/Oct/11 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Major |
| Reporter: | David Nolen | Assignee: | David Nolen |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Description |
(let [x '(1 2) y 1]
(match [x y]
[([1] :seq) _] :a0
[_ 1] :a1
[([1 2] :seq) _] :a2
[_ 2] :a3
:else :a4))
This returns :a2 when it should return :a1 |
| Comments |
| Comment by David Nolen [ 09/Oct/11 2:22 PM ] |
|
Fixed, https://github.com/clojure/core.match/commit/efa880320fc235536690ba8af078a59c17f3321d |
[MATCH-27] match eats exceptions Created: 06/Oct/11 Updated: 06/Oct/11 Resolved: 06/Oct/11 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Major |
| Reporter: | mindslight | Assignee: | David Nolen |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
match 0.2.0-alpha4, clojure 1.2.0 |
||
| Description |
|
user=> (match-1 :a :a (throw (Exception.)) :else :c) I would expect the exception to flow through the match. Instead, it gets eaten and one is left wondering why the proper clause "isn't matching". |
| Comments |
| Comment by David Nolen [ 06/Oct/11 10:51 PM ] |
|
Fixed, https://github.com/clojure/core.match/commit/94f240dee09434ab87d2f901c647fdbd73792e89 |
[MATCH-24] Setting *warn-on-reflection* affects all code using core.match Created: 03/Oct/11 Updated: 03/Oct/11 Resolved: 03/Oct/11 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Major |
| Reporter: | Hugo Duncan | Assignee: | David Nolen |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Setting warn-on-reflection affects all use of core.match. Please remove all cases where warn-on-reflection is set. This can be set by the pom for the project, rather than in source, so it doesn't affect code using core.match. |
| Comments |
| Comment by David Nolen [ 03/Oct/11 7:38 AM ] |
|
Fixed, https://github.com/clojure/core.match/commit/f75152edb697cff9bbe9070478b5bc0105f140ca Do you have an example of setting it in the POM? |
| Comment by Hugo Duncan [ 03/Oct/11 11:32 AM ] |
|
Thanks! I assume the clojure build is using clojure-maven-plugin, in which case it is just a matter of setting warnOnReflection. Something like this (untested): <build> <plugins> <plugin> <groupId>com.theoryinpractise</groupId> <artifactId>clojure-maven-plugin</artifactId> <configuration> <warnOnReflection>true</warnOnReflection> </configuration> </plugin> </plugins> </build> |
[MATCH-28] clojure.core.match ns instead of clojure.core.match.core Created: 09/Oct/11 Updated: 10/Oct/11 Resolved: 10/Oct/11 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Enhancement | Priority: | Major |
| Reporter: | David Nolen | Assignee: | David Nolen |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Comments |
| Comment by David Nolen [ 10/Oct/11 10:34 PM ] |
|
Fixed, https://github.com/clojure/core.match/commit/af647a77415f5a8c8cc3d1222873b55f91241dde |
[MATCH-29] match should not throw, return nil if no match found like cond Created: 09/Oct/11 Updated: 10/Oct/11 Resolved: 10/Oct/11 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Major |
| Reporter: | David Nolen | Assignee: | David Nolen |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Comments |
| Comment by David Nolen [ 10/Oct/11 10:55 PM ] |
|
Fixed, https://github.com/clojure/core.match/commit/c9e47acfc7dd4364428cfe011476a3492787f050 |
[MATCH-30] throw if binding name reused in the same pattern row Created: 10/Oct/11 Updated: 19/Oct/11 Resolved: 19/Oct/11 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Major |
| Reporter: | David Nolen | Assignee: | David Nolen |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Patch: | Accepted |
| Approval: | Ok |
| Comments |
| Comment by Steve Miner [ 15/Oct/11 3:43 PM ] |
|
Checks for duplicate wildcard names in a pattern row. |
| Comment by David Nolen [ 15/Oct/11 4:05 PM ] |
|
You should be able to reuse bindings as is done in the red black tree pattern as there is no ambiguity there. If we can get that enhancement in I'll gladly accept this. Thanks for taking this on! |
| Comment by Steve Miner [ 16/Oct/11 3:53 PM ] |
|
The new patch allows OR patterns to reuse wildcards, but still complains if there are other ambiguities. I added a couple of tests to illustrate. |
| Comment by David Nolen [ 17/Oct/11 10:33 AM ] |
|
This looks good. It looks like you created this patch before I added your match-let. Mind creating a new version of this patch against HEAD? Thanks much. |
| Comment by Steve Miner [ 18/Oct/11 2:47 PM ] |
|
Updated patch for latest HEAD |
| Comment by David Nolen [ 18/Oct/11 7:14 PM ] |
|
I'm trying to apply with patch with git am, but I keep getting: Applying: * src/main/clojure/clojure/core/match.clj: Add Stephen Miner's match-let It looks like the previous commit of my pasting of your match-let patch is mixed up into your latest patch. |
| Comment by Steve Miner [ 19/Oct/11 7:22 AM ] |
|
Sorry, I made a git mistake with dup3.patch. I made a fresh patch called dup4.patch that should fix the problem. |
| Comment by David Nolen [ 19/Oct/11 9:57 AM ] |
|
Fixed https://github.com/clojure/core.match/commit/819f7f7d874f63b74ba634a9bebc95da574d80eb |
[MATCH-34] remove infix or pattern syntax, use (:or x y z) instead Created: 21/Oct/11 Updated: 27/Oct/11 Resolved: 27/Oct/11 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Major |
| Reporter: | David Nolen | Assignee: | David Nolen |
| Resolution: | Completed | Votes: | 1 |
| Labels: | None | ||
| Comments |
| Comment by David Nolen [ 27/Oct/11 11:17 PM ] |
|
Fixed, https://github.com/clojure/core.match/commit/0195f7211d44e15d40a35445b4882fcaf5bc9fb6 |
[MATCH-37] remove match-1, match should support match-1 behavior Created: 28/Oct/11 Updated: 28/Oct/11 Resolved: 28/Oct/11 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Enhancement | Priority: | Major |
| Reporter: | David Nolen | Assignee: | David Nolen |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
matching literal vectors is not something we support so there can be no ambiguity. |
| Comments |
| Comment by David Nolen [ 28/Oct/11 12:31 AM ] |
|
Fixed, https://github.com/clojure/core.match/commit/5edc28c6cd5315818ec2a852e931f5b7fe7dff35 |
[MATCH-42] quoted symbols should be treated as literals Created: 30/Nov/11 Updated: 30/Nov/11 Resolved: 30/Nov/11 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Major |
| Reporter: | Steve Miner | Assignee: | David Nolen |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Description |
|
Reported on the Clojure mailing list: From: Alex Miller <alex@puredanger.com> I've been working with core.match some this week and finding it pretty ;; translate (+ x (+ y z)) to (+ x y z) You will see this error: Any symbol inside a pattern row is treated as a bind variable. + is a (defn +? [s] (= '+ s)) (let [e '(+ 1 (+ 2 3))] but, yuck. I can imagine using the reserved ()'s with additional keys (let [e '(+ 1 (+ 2 3))] These come through as (quote x) although the error reporting goes a However, that seems fixable and you could then use (quote x) as a |
| Comments |
| Comment by Steve Miner [ 30/Nov/11 4:56 PM ] |
|
Skip anything that's quoted when looking for duplicate symbol names. Added a test for the reported case. |
| Comment by Steve Miner [ 30/Nov/11 4:57 PM ] |
|
patch attached |
| Comment by David Nolen [ 30/Nov/11 6:52 PM ] |
|
Fixed, https://github.com/clojure/core.match/commit/6721be4fba74561038539e12667bc04cc5fc94cc |
[MATCH-41] This 5-clause match expression fails to compile Created: 30/Nov/11 Updated: 30/Nov/11 Resolved: 30/Nov/11 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Major |
| Reporter: | Gary Fredericks | Assignee: | David Nolen |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Ubuntu 10.10 java version "1.6.0_20" |
||
| Description |
|
This expression fails to compile with a NullPointerException. Oddly enough I seem unable to make it any more minimal: (match [["foo"]] [["foo"]] :a0 [["foo" a]] :a1 [["baz"]] :a2 [["baz" a b]] :a3) When I included the SNAPSHOT release in my project that seemed to fix it, but oddly enough I cloned the git repo this morning and it was still broken on HEAD, so I have no idea what's going on. |
| Comments |
| Comment by David Nolen [ 30/Nov/11 8:12 PM ] |
|
Fixed, https://github.com/clojure/core.match/commit/a790f7900da9152dcdf290ade34b8001c47869f1 |
[MATCH-46] :or leaks into the matches Created: 22/Dec/11 Updated: 22/Dec/11 Resolved: 22/Dec/11 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Major |
| Reporter: | David Nolen | Assignee: | David Nolen |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Macroexpanding an match expression with an :or pattern will show this. |
| Comments |
| Comment by David Nolen [ 22/Dec/11 12:52 AM ] |
|
Fixed, https://github.com/clojure/core.match/commit/c1430c98937f31a0c8d2a92d793b0795b2c9a1d6 |
[MATCH-45] group types together Created: 21/Dec/11 Updated: 23/Dec/11 Resolved: 23/Dec/11 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Major |
| Reporter: | David Nolen | Assignee: | David Nolen |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Currently if patterns of the same type are not adjacent, matching fails unexpectedly. This should always work. This does beg the question about things which might possible match multiple clauses. When we get to predicate dispatch we may check for subsumption. However in some cases we might have something which is legitimately both things. We haven't decided yet how we'll handle that. |
| Comments |
| Comment by David Nolen [ 23/Dec/11 10:09 PM ] |
|
Fixed, https://github.com/clojure/core.match/commit/29607a2105d8af90c5b8d9d4cde9191e63a2570c |
[MATCH-43] Vector pattern - unreachable clause Created: 10/Dec/11 Updated: 27/Dec/11 Resolved: 27/Dec/11 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Major |
| Reporter: | Benny Tsai | Assignee: | David Nolen |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Clojure 1.3, core.match 0.2.0-alpha8 |
||
| Description |
|
This is the simplest example I could come up with: (defn f [xs] [:a] and [:b b] can be matched with no problems, but [:c] can't be matched for some reason: user=> (f [:a]) |
| Comments |
| Comment by David Nolen [ 12/Dec/11 9:24 PM ] |
|
This will have to wait for http://dev.clojure.org/jira/browse/MATCH-31. There are some deeper issues with vector pattern matching that need to get ironed out first. In the meantime just put your [:c] test above [:b b]. The key idea is to keep vector patterns of the same size "together". |
| Comment by David Nolen [ 27/Dec/11 8:23 PM ] |
|
fixed, https://github.com/clojure/core.match/commit/b2ee29d701a9306c1c494d91c371c01a512aee0c |
[MATCH-62] ClojureScript map-matching should use cljs.core/ILookup, not cljs.core.ILookup Created: 30/Jun/12 Updated: 01/Jul/12 Resolved: 01/Jul/12 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Major |
| Reporter: | Kevin Lynagh | Assignee: | David Nolen |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Description |
|
The latter form is an implementation detail and doesn't work in the latest cljs compiler release. |
| Comments |
| Comment by Kevin Lynagh [ 30/Jun/12 12:10 PM ] |
|
Patch against master to use cljs.core/ILookup. Also available at https://github.com/lynaghk/core.match/tree/62-cljs-protocol |
| Comment by David Nolen [ 01/Jul/12 11:05 AM ] |
|
fixed, http://github.com/clojure/core.match/commit/241a3a3ab5344cc7c97fb3ab0b3783ce97b09f6d |
[MATCH-50] locals pattern matching issue Created: 12/Jan/12 Updated: 25/Feb/12 Resolved: 25/Feb/12 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Major |
| Reporter: | David Nolen | Assignee: | David Nolen |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Description |
(let [a 1]
(match [1 2]
[1 3] :a0
[a 2] :a1
:else :a2)) ;; :a2
|
| Comments |
| Comment by David Nolen [ 25/Feb/12 6:49 PM ] |
|
Fixed, https://github.com/clojure/core.match/commit/ac92c6df3f70f56fbe12f9d3f46585e66102c50b |
[MATCH-67] match broken on ClojureScript >= 88b36c1 Created: 14/Feb/13 Updated: 15/Feb/13 Resolved: 15/Feb/13 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Major |
| Reporter: | Chas Emerick | Assignee: | David Nolen |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
The ClojureScript example in core.match's readme is failing at the moment, using core.match 0.2.0-alpha11: (ns foo.bar
(:use-macros [clojure.core.match.js :only [match]]))
(match [(mod 5 3) (mod 5 5)]
[0 0] "FizzBuzz"
[0 _] "Fizz"
[_ 0] "Buzz"
:else n)
ClojureScript:foo.bar> WARNING: Use of undeclared Var foo.bar/e__4345__auto__ at line 4
clojure.lang.ExceptionInfo: Unsupported binding form: (if (clojure.core/identical? e__4345__auto__ 0) (do (clojure.core/let [ocr-5230 (mod 5 5) ocr-5229 (mod 5 3)] (try (clojure.core/cond (clojure.core/= ocr-5230 0) (clojure.core/let [G__5226 ocr-5229] "Buzz") :else (throw 0)) (catch e__4345__auto__ (if (clojure.core/identical? e__4345__auto__ 0) (do (clojure.core/let [G__5228 ocr-5230 G__5227 ocr-5229] n)) (throw e__4345__auto__)))))) (throw e__4345__auto__)) at line 4 {:tag :cljs/analysis-error, :file nil, :line 4}
The same error is produced with any usage of match in ClojureScript AFAICT, not just the README example. However, all is well with core.match AFAICT under Clojure, and if you use older revs of ClojureScript, e.g. r1552. I did a bisect, and found that this is the first ClojureScript commit with which the example does not work: https://github.com/clojure/clojurescript/commit/88b36c1 Reverting it with master results in proper evaluation of the match, modulo the warning. I don't see any obvious reason why the above would cause any problems, and some moderate digging based on what I know about ClojureScript didn't yield any ah-ha! moments. |
| Comments |
| Comment by David Nolen [ 15/Feb/13 5:21 PM ] |
|
fixed http://github.com/clojure/core.match/commit/3bab92b6620dccdcb9e55941af4599e3adf78a6e |
| Comment by Chas Emerick [ 15/Feb/13 7:51 PM ] |
|
Thanks for looking at this! |
[MATCH-66] Cannot match entire/single value Created: 06/Jan/13 Updated: 18/May/13 Resolved: 18/May/13 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Major |
| Reporter: | Chas Emerick | Assignee: | David Nolen |
| Resolution: | Completed | Votes: | 1 |
| Labels: | None | ||
| Description |
=> (match 3 x x)
CompilerException java.lang.RuntimeException: Unable to resolve symbol: ocr-34984 in this context, compiling:(NO_SOURCE_PATH:1:1)
=> (macroexpand '(match 3 x x))
(let* [x ocr-35001] x)
(Discussed briefly here.) |
| Comments |
| Comment by David Nolen [ 18/May/13 2:18 PM ] |
|
fixed, http://github.com/clojure/core.match/commit/02a833efb959e0518f264ded3b98ce4215b5622c |
[MATCH-59] Misleading comment in clojure.core.match.bits Created: 19/May/12 Updated: 18/May/13 Resolved: 18/May/13 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Enhancement | Priority: | Major |
| Reporter: | Thomas Greve Kristensen | Assignee: | David Nolen |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
I was looking at the code for clojure.core.match.bits, and there seems to be a reference to an example of parsing a dgram. The code looks to be broken or incomplete, or is it my understanding of it that is lacking? If it isn't done, are there any plans to finish it up? |
| Comments |
| Comment by David Nolen [ 18/May/13 2:21 PM ] |
|
The bits and array namespaces are experimental I've left a comment in both namespaces that states that. http://github.com/clojure/core.match/commit/511b786b9545f5c00a629fa27be0ee2a6b01e2ae |
[MATCH-5] Rest patterns should infer their type Created: 04/Sep/11 Updated: 26/Sep/11 Resolved: 26/Sep/11 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Enhancement | Priority: | Minor |
| Reporter: | David Nolen | Assignee: | David Nolen |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Rest patterns don't currently infer their type. A simple enhancement that would save some extra typing as well as potentially mysterious errors. |
| Comments |
| Comment by David Nolen [ 26/Sep/11 6:58 AM ] |
|
Fixed, https://github.com/clojure/core.match/commit/d8e767948977837bfb138b9383d6f7c2d175c09e |
[MATCH-3] strange infinite lazy seq of nils pattern rows bug at leaf nodes Created: 04/Sep/11 Updated: 25/Sep/11 Resolved: 25/Sep/11 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Minor |
| Reporter: | David Nolen | Assignee: | David Nolen |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
This is low priority, but should be investigated. To see this behavior just print out the pattern row at the leaf node cases. Encountered this while fixing symbol binding bug in vector patterns. |
| Comments |
| Comment by David Nolen [ 25/Sep/11 6:45 PM ] |
|
Fixed, https://github.com/clojure/core.match/commit/7ceffec3876b5175f33182e75c91e2c8046a19e4 |
[MATCH-32] Allow flattened pattern syntax at top-level to avoid nesting :when and :as Created: 12/Oct/11 Updated: 21/Oct/11 Resolved: 21/Oct/11 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Enhancement | Priority: | Minor |
| Reporter: | Steve Miner | Assignee: | Unassigned |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Patch: | Accepted |
| Approval: | Ok |
| Description |
|
On the Clojure mailing list I wrote: For guards, I wonder if the extra parens are really necessary. Couldn't the :when bind tightly to the previous pattern variable? Like Clojure FOR comprehensions. I think it would be easier to read that way. Same comment applies to :as. To cover the rare case of matching a literal :when or :as, you could quote it or use it as the first item in an OR pattern. On Oct 10, 2011, at 3:11 PM, David Nolen wrote: It would be nice to lose the extra parens - patch welcome |
| Comments |
| Comment by Steve Miner [ 12/Oct/11 10:35 AM ] |
|
I attached a patch that groups the :when and :as terms appropriately given a "flattened" syntax. That is, [a :when even?] becomes [(a :when even?)] before being processed as usual. I only applied it to the top-level of the pattern row because I was concerned about recursive performance and things can get pretty complicated so maybe the magic isn't worth it. Only :when and :as at the top level get any special treatment. No mangling for :seq or ::vector, etc. No mangling of nested patterns. I also added a couple of tests for my changes. |
| Comment by Steve Miner [ 14/Oct/11 1:03 PM ] |
|
I wrote an improved patch that should handle nested patterns as well. Still only groups :when and :as, not :seq since that seems sort of special. |
| Comment by Steve Miner [ 15/Oct/11 7:59 AM ] |
|
Better to use seq? instead of list? |
| Comment by David Nolen [ 15/Oct/11 10:24 AM ] |
|
At first glance this looks pretty neat! Will try to take a deeper look today. Thanks! |
| Comment by David Nolen [ 15/Oct/11 10:47 AM ] |
|
One issue I have with this syntax enhancement - how does one match :when or :as as literals? |
| Comment by Steve Miner [ 15/Oct/11 3:13 PM ] |
|
The patch tries to group the :when or :as if that makes sense. If it doesn't make sense [:when true nil], it leaves it alone so that would match the literal. In the rare case where it would be ambiguous, you would have to use a single OR pattern to get a literal match, such as [a (:when |) false]. I put something like that in one of my new tests. |
| Comment by Steve Miner [ 15/Oct/11 3:18 PM ] |
|
By the way, it might be nice to allow a single element list to match that single pattern. That is, treat [(p)] the same as [p]. Right now, it's considered an error. It would also simply my patch, where I had to introduce interpose1 (as a variant of interpose) to handle an edge case with the OR pattern. |
| Comment by David Nolen [ 20/Oct/11 1:54 PM ] |
|
I'm not a fan of (:when |). I'd prefer it if the patch included support for always matching literal keywords that are written as ':foo. |
| Comment by Steve Miner [ 20/Oct/11 3:04 PM ] |
|
Revised patch to support ':when (and quoted keywords in general) to match the literal keyword. Updated against HEAD. |
| Comment by David Nolen [ 21/Oct/11 6:53 PM ] |
|
Fixed, https://github.com/clojure/core.match/commit/d69abfaf68a86d5b9d73070e666720770779118f |
[MATCH-38] interpose1 no longer needed Created: 29/Oct/11 Updated: 29/Oct/11 Resolved: 29/Oct/11 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Enhancement | Priority: | Minor |
| Reporter: | Steve Miner | Assignee: | David Nolen |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
With the fix for |
| Comments |
| Comment by David Nolen [ 29/Oct/11 12:50 PM ] |
|
Fixed, https://github.com/clojure/core.match/commit/314c665197bf6f74ed5e66518e93b48f5778ff60 |
[MATCH-44] regroup-keywords should not use gensym Created: 12/Dec/11 Updated: 12/Dec/11 Resolved: 12/Dec/11 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Enhancement | Priority: | Minor |
| Reporter: | Steve Miner | Assignee: | David Nolen |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Patch: | Code |
| Description |
|
I contributed the regroup-keywords function to allow 'flattened' match syntax for :when and :as. It used gensym to make a marker to simplify the algorithm. After seeing how other people had done similar things with sentinel values, I realized that (Object.) is a better unique value. Theoretically, an evil user could use the same symbol that the gensym had created. Also, it's better to test with identical? rather than = since the sentinel is unique. I will attach a patch with a slight refactoring. |
| Comments |
| Comment by David Nolen [ 12/Dec/11 9:30 PM ] |
|
Fixed, https://github.com/clojure/core.match/commit/6d0f3fe33c4a85a12366d447e82cab59e299f94a |
[MATCH-60] Matching maps with :only broken in CLJS Created: 18/Jun/12 Updated: 01/Jul/12 Resolved: 01/Jul/12 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Minor |
| Reporter: | Kevin Lynagh | Assignee: | David Nolen |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Patch: | Code |
| Description |
|
The `.keySet` method call doesn't exist on JavaScript objects. |
| Comments |
| Comment by David Nolen [ 18/Jun/12 10:49 AM ] |
|
It would preferable to check the *clojurescript* dynamic var and do different emission. Thanks! |
| Comment by Kevin Lynagh [ 30/Jun/12 11:34 AM ] |
|
Updated patch against master that uses clojurescript var. Also available at https://github.com/lynaghk/core.match/tree/60-cljs-keyset |
| Comment by David Nolen [ 01/Jul/12 11:03 AM ] |
|
fixed, http://github.com/clojure/core.match/commit/cdeea55f211f1dbe4768c8aec3149bfcb00438a2 |
[MATCH-48] Guards cannot be fn expressions Created: 10/Jan/12 Updated: 25/Feb/12 Resolved: 25/Feb/12 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Minor |
| Reporter: | Chris Gray | Assignee: | David Nolen |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Patch: | Code and Test |
| Description |
|
Anonymous function literals as guards (such as (a :when #(odd? %))) seem to confuse the match compiler. The attached test shows how. |
| Comments |
| Comment by David Nolen [ 10/Jan/12 10:04 PM ] |
|
I'm on the fence about allowing inline fn expressions and fn literals as guards. The problem is that they can't be checked for equality and thus tests cannot be shared across guard patterns. I need to think about it some more but I don't consider this high priority in the near future. Any decision will have to take into consideration the goal of predicate dispatch. |
| Comment by Chris Gray [ 11/Jan/12 12:41 PM ] |
|
Sorry, I think the fact that the functions in my earlier example were function literals was a bit of a red herring. The following test also fails. (deftest guard-pattern-match-5
(is (=
(let [oddp odd?]
(match [1 2]
[a :when odd? b :when odd?] :a1
[a :when oddp _] :a2
[_ b :when even?] :a3
:else :a4))
:a2)))
|
| Comment by David Nolen [ 11/Jan/12 12:44 PM ] |
|
The earlier examples where not a red herring. This is likely a separate issue. |
| Comment by Chris Gray [ 11/Jan/12 12:50 PM ] |
|
I really don't see how, given that there seems to be no code that specializes on the type of function given to a guard. My guess is that when guard-pattern-match-5 succeeds, guard-pattern-match-4 will succeed as well. |
| Comment by David Nolen [ 11/Jan/12 1:00 PM ] |
|
Oh sorry you are right. This is exactly same problem. We can't know that odd? and oddp are the same. Again this is not something I'm interested in fixing without a lot more consideration. Basically functions can't be tested for equality like types can. This means that the presence of a guard must create a backtrack point. However if we make guards work a little more like types (you have to declare them ahead of time) we lose a little bit of convenience but gain a lot of reasoning power and can share tests and avoid these pitfalls. This discussion probably needs a design page. |
| Comment by Chris Gray [ 11/Jan/12 6:11 PM ] |
|
Two more examples of the same problem, this time not using guards: (deftest unequal-equal-tests
(is (=
(match ["foo" "bar"]
[#".*" #"baz"] :a1
[#"foo" _] :a2
[_ "bar"] :a3
:else :a4)
:a2)))
(deftest unequal-equal-tests-2
(is (=
(let [a 1]
(match [1 2]
[(:or 1 2) 3] :a1
[(:or 2 a) 2] :a2
[1 _] :a3
:else :a4))
:a2)))
|
| Comment by David Nolen [ 11/Jan/12 6:58 PM ] |
|
They are not the same problem. These don't work for very different reasons. The first I probably won't even address and will leave for the community to deal with - I don't need robust pattern matching on regexes. The second example is a legitimate bug around matching locals which is unrelated to this ticket. Feel free to open a new one for it. |
| Comment by Chris Gray [ 11/Jan/12 7:15 PM ] |
|
Yes, you're right, the second is unrelated. |
| Comment by Chris Gray [ 12/Jan/12 11:20 AM ] |
|
On further reflection, what all these examples show is that Maranget's algorithm is only correct for literals whose equality you can test at compile time. Thus, not even locals will work using his algorithm. Regexes and functions will certainly not work correctly 100% of the time. What happens is that when multiple unequal tests in the same column can return a truthy value, you end up with a decision forest rather than a decision tree. If the first decision tree in the forest has the first and third end-states, while the second tree has the second end-state, if you end up in the third end-state, you must still check the second decision tree before you decide which end-state is actually correct. This is a shame, since it means that compiling the matches becomes more complex. On the other hand, it seems like a great subject for a paper at programming-language conference, so there's always that. On a serious note, though, this bug is major, and you should consider removing support for at least guards, locals, and regexes until it is fixed. The bugs that arise from it in the end-user's code are really hard to track down – it's as if `or` or `and` were broken 10% of the time. |
| Comment by David Nolen [ 12/Jan/12 11:29 AM ] |
|
There is nothing wrong with Maranget's algorithm. We just have to be sure that we create a backtrack point - that's all. Functions cannot be fixed because function equality is undecideable. So for guards we might create a backtrack point. I've already updated the README to describe what works at the moment. I have a branch which throws an error if :when is not given a vector of symbols or a symbol. It should probably be improved so that symbols are known top levels (no reassigning fns to locals). Regex equality can probably be made to work but I'm not going to do it. (On further thought we can probably make patterns create backtrack points by default, can be overridden for those willing to make their patterns highly optimizeable) Locals can be fixed, we'll definitely create a backtrack point for these. |
| Comment by Chris Gray [ 12/Jan/12 11:54 AM ] |
|
I'm sorry, but this problem will not be solved by backtracking alone. At least not with the backtracking mechanism that currently exists. With backtracking, you are still treating the problem as though you have a decision tree. A decision tree requires that all the tests at its nodes are mutually exclusive. By assuming that you have a decision tree, once a match is found in the tree, that match is returned. As my last comment pointed out, that is not sufficient. You must also check to see if there is a match in an end-state that was declared earlier. I really don't see that that's possible given the current backtracking system. |
| Comment by David Nolen [ 12/Jan/12 1:26 PM ] |
|
I don't follow you. Maranget's algorithm is not sufficient for pattern matching if we don't constrain columns to specific types. There are many things already in place to deal with the shortcomings of Maranget's approach given what we want to accomplish - for example, we actually have a grouping pass. This is the same approach that Racket uses as far as I can tell and they don't have any problems. Certainly none of the patterns you shown thus that far (besides fns exprs) pose any challenges that I can see. |
| Comment by Chris Gray [ 12/Jan/12 1:42 PM ] |
|
Sorry, I was editing my comment as you made yours. I hope it is more clear now. I guess I don't totally understand your code still, so I will try to rectify that before commenting again. From what I have seen, though, you are trying to build a decision tree. What I am saying is that isn't possible at compile time, since you can't ensure that the nodes of the tree are mutually exclusive. |
| Comment by David Nolen [ 12/Jan/12 1:51 PM ] |
|
All known constructors are considered mutually exclusive. We group all constructors in a column preserving order as closely as possible. Decisions trees are created for these constructors. If we cannot know at compile time whether something is mutually exclusive (wildcards, locals), we create a backtrack point to handle them. Consider that if we only have backtrack points (no trees) all tests could potentially be tried. Our approach is a hybrid one - we don't rely only on decisions trees and we don't rely only on backtracking. When we get to integrating pattern matching on interfaces, protocols ambiguities of course become possibly. But even this can probably be handled reasonably with something like "prefers". |
| Comment by Chris Gray [ 12/Jan/12 3:07 PM ] |
|
Consider the following pair of decision trees: 1 / a \ 3* 2* / b--4* \ 5* Where the numbers are the order in which the terminals appear, and they have stars beside them if they match. The correct terminal for core.match to return in this case is the second one. Currently, the code would return the third terminal. Suppose, however, that backtracking was added so that the tree rooted at b was checked for matches as well. This is certainly possible, though a lot of information would need to be kept about the match already found (which is what I meant about things not working with the current backtracking system). Also, you must ensure that the testing stops when you hit the second terminal, for two reasons – first, not doing so would imply that all terminals are checked, and second, the test to distinguish 4 from 5 could throw an exception. For similar reasons, the return value of the third terminal can't be computed – it could be a very long computation, or it could throw an exception. |
| Comment by David Nolen [ 12/Jan/12 3:28 PM ] |
|
If the correct terminal is the second one, we will return the second one. No information needs to be kept around. I suggest you take a closer look at the code at this point. |
| Comment by Chris Gray [ 12/Jan/12 6:58 PM ] |
|
Aah, you're right. (I think.) Might it be more accurate to say that the situation I proposed can't happen? That is, no two trees are created where there are lower-numbered terminals in the second tree than in the first tree? Is the plan to add backtrack points for everything where equality can't be determined at compile time? |
| Comment by Chris Gray [ 12/Jan/12 11:27 PM ] |
|
These patches implement the proper backtracking for tests that are not mutually exclusive. |
| Comment by David Nolen [ 13/Jan/12 9:15 AM ] |
|
Wow, this is great. I've skimmed over the patches and they look pretty good. I will go over them more closely as soon as I can - there are a couple changes we should probably make. Thanks! |
| Comment by Chris Gray [ 13/Jan/12 11:08 AM ] |
|
No problem. My apologies for the persistent misunderstanding. |
| Comment by David Nolen [ 14/Feb/12 4:39 PM ] |
|
Sorry for the epic delay. Here are my notes on that patches: 1. Let's rename mutually-exclusive-inequality? to comparable? If you make these changes I promise to apply these in a timely manner |
| Comment by Chris Gray [ 15/Feb/12 12:50 PM ] |
|
Okay, patch uploaded. There is a fairly significant portion of it that is just cut and paste, which I'm not so happy about, but I don't think there's a way to do type inheritance, so I did the easier thing. |
| Comment by David Nolen [ 25/Feb/12 6:49 PM ] |
|
Fixed, https://github.com/clojure/core.match/commit/ac92c6df3f70f56fbe12f9d3f46585e66102c50b addressed |
[MATCH-33] typo in README.md Created: 20/Oct/11 Updated: 27/Oct/11 Resolved: 27/Oct/11 |
|
| Status: | Resolved |
| Project: | core.match |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Trivial |
| Reporter: | Steve Miner | Assignee: | David Nolen |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Re: "As shown, :else clauses are special, in that they are not implicitely wrapped in []." "implicitely" is misspelled, but "implicitly" would be the wrong word anyway as the intended meaning seems to be "explicitly". It would be clearer just to leave out the adverb. |
| Comments |
| Comment by David Nolen [ 27/Oct/11 11:19 PM ] |
|
Fixed, https://github.com/clojure/core.match/commit/1399a77e7833abb3a41be538a6356bc3bd871152 |