Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 1.0
-
Fix Version/s: 1.1-beta-2
-
Component/s: None
-
Labels:None
-
Environment:groovy-1.0 on jre1.6.0 on WinXP prof edn
-
Number of attachments :
Description
//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']
should be fixed in HEAD