Issue Details (XML | Word | Printable)

Key: GROOVY-1685
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Paul King
Reporter: Gavin Grover
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
groovy

using ranges as list subscripts limited to existing list size

Created: 30/Jan/07 08:18 AM   Updated: 26/Sep/07 08:27 PM
Component/s: None
Affects Version/s: 1.0
Fix Version/s: 1.1-beta-2

Time Tracking:
Not Specified

Environment: groovy-1.0 on jre1.6.0 on WinXP prof edn


 Description  « Hide
//Using both integers and ranges as list subscripts OK when within existing list size...
list = ['a','b','c']; list[1] = 'x'; assert list == ['a','x','c']
list = ['a','b','c']; list[3] = 'x'; assert list == ['a','b','c','x']
list = ['a','b','c']; list[1..2] = ['x','y']; assert list == ['a','x','y']

//but only integers OK when outside existing list size...
list = ['a','b','c']; list[4] = 'x'; assert list == ['a','b','c',null,'x']

//Ranges as list subscripts outside existing list size cause an out-of-bounds exception...
list = ['a','b','c']; try{ list[2..3] = ['x','y'] }catch(Throwable e){ assert e instanceof IndexOutOfBoundsException }
list = ['a','b','c']; try{ list[4..5] = ['x','y'] }catch(Throwable e){ assert e instanceof IndexOutOfBoundsException }

//The desired behavior is:
list = ['a','b','c']; list[2..3] = ['x','y']; assert list == ['a','b','x','y']
list = ['a','b','c']; list[4..5] = ['x','y']; assert list == ['a','b','c',null,'x','y']



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Paul King added a comment - 10/Jun/07 08:14 PM
should be fixed in HEAD

Paul King added a comment - 26/Sep/07 08:27 PM
No further feedback, assuming fixed