Chas Emerick
unread,Apr 22, 2013, 1:09:55 PM4/22/13Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to cloju...@googlegroups.com
I hit a couple of bugs in core.match involving & rest vector patterns. I made some progress (reflected in the attached WIP .diff), but have hit a wall.
First bug:
(match [[:x]]
[[m n & _]] 1)
=> IndexOutOfBoundsException
Essentially, vector rest patterns weren't producing necessary size checks prior to using subvec. I fixed this by adding another variant of `test-inline` that is emitted only by vector rest patterns.
That change is safe and does not cause any regressions in the core.match test cases, but did in my app's. I boiled it down to this minimal example:
(match [[[:x "t"]]]
[[[:x & a] & tail]] :a
[[[:y & p] [:x & a] & tail]] :b)
=> nil
In the emitted code, the first case would never be matched. I tweaked the relevant return values in pattern-compare (which always returned 0 for patterns of the same size?). That fixed this case, but regressed vector-pattern-rest-2.
It was at this point that I realized that pattern-compare wasn't isomorphic to other *compare fns (it only is used to determine equality or not?), and discovered the & rest vector pattern dropping logic in `first-column-chosen-case` (neither of which I've come to grok at all).
My app is doing well enough with a SNAPSHOT that uses the "fixes" so far, but I'd like to nail down that regression. The addition of test-with-min-size-inline (or something like it) is necessary in any case to avoid the IOOBE, but I feel quite over my head at this point w.r.t. the pattern "ordering" / rest vector pattern pruning. Any hints?
Thanks,
- Chas