<< Back to previous view

[MATCH-68] Vector match "underflow" => IndexOutOfBoundsException Created: 22/Apr/13  Updated: 28/Jul/13  Resolved: 16/Jun/13

Status: Closed
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

Attachments: File vector-rest-WIP.diff    
Patch: Code and Test

 Description   

This fails with 0.2.0-alpha12:

(match [[:x]]
  [[m n & _]] 1)

I expect nil, but an unguarded subvec call throws an IndexOutOfBoundsException.

A WIP patch is attached that fixes this (perhaps incorrectly) but which produced regressions (outside of core.match), e.g.

(match [[[:x "t"]]]
 [[[:x & a] & tail]] :a
 [[[:y & p] [:x & a] & tail]] :b)
=> nil

The patch also "fixes" this (by changing pattern-compare behaviour for rest VectorPattern s, but that leads to a regression in the vector-pattern-rest-2 testcase in core.match.

(Original discussion with further background here.)



 Comments   
Comment by Greg Chapman [ 24/Apr/13 5:26 PM ]

FWIW, I've been using the patch described here, and haven't yet run into any problems, though I also haven't used core.match that much. Anyway, with the change to subvec-inline, both of the cases here act as expected (producing nil and :a, respectively).

(I note looking at my patch that I'm doubly-evaluating ocr in the second overload; obviously that should be fixed with a let binding).

Comment by David Nolen [ 18/May/13 3:11 PM ]

The patch looks like it's going in the right direction. Can you explain why your patch without the pattern-compares case causes the second example to fail?

Comment by David Nolen [ 16/Jun/13 10:10 PM ]

fixed, http://github.com/clojure/core.match/commit/302c355ebf751fa8dc442c8db8b901ebb4eacfae

Generated at Thu Apr 24 10:00:55 CDT 2014 using JIRA 4.4#649-r158309.