[MATCH-70] Matches against maps are treated as wildcards, even though they are not Created: 29/May/13 Updated: 28/Jul/13 Resolved: 15/Jun/13
|Reporter:||David Pollak||Assignee:||David Nolen|
|Patch:||Code and Test|
The following tests fail:
|Comment by David Nolen [ 29/May/13 8:26 PM ]|
Thanks for the patch but this won't work - this defeats sharing tests. I'm looking into it.
|Comment by David Pollak [ 29/May/13 10:38 PM ]|
Thanks David. I was thinking about putting a "is this really a wildcard" flag on Wildcard and set it to false for Wildcards in MapPattern.
Anyway... if you want me to keep working on the issue, I'll be glad to. If my clumsy code and clumsy approach doesn't help... I'm down for sitting on the sidelines and watching you do the work.
|Comment by David Nolen [ 30/May/13 12:35 AM ]|
The issue is a bit trickier than it seems. core.match is written in a way such that we always try to share tests across patterns as much as possible. For example consider what happens with map patterns:
In order to do optimal test sharing we expand the above into the following more or less (which is wrong):
The problem here is that only the last element in the first row and the first element of the second row are true wildcards. Currently as you discovered the analysis doesn't consider the fact that the other wildcards really must be tested. So really we want something like the following:
Here you can see we wrap the wildcard in a new pattern type - MapValuePattern. This will prevent the bad analysis.
I hope this makes sense - I've started implementing this and I don't think it will take me too long.
Just to make it a bit more clear imagine the following:
The wrapping now prevents the first row from being considered a row of wildcards.
|Comment by David Nolen [ 02/Jun/13 11:33 AM ]|
This should be fixed in master as of this commit http://github.com/clojure/core.match/commit/a07c2e9620df5b9d331bd6c380d47c15bf7cd60d
Let me know if it works for you.
|Comment by David Pollak [ 02/Jun/13 1:00 PM ]|
Awesome. Thanks! Please let me know when there are new JAR files in clojars.
|Comment by David Nolen [ 15/Jun/13 10:30 PM ]|
this has been resolved http://github.com/clojure/core.match/commit/a07c2e9620df5b9d331bd6c380d47c15bf7cd60d