File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -157,6 +157,7 @@ function removeChild(container: Doc[] | DocObj, key: Key) {
157157function insertChildMut ( container : Doc [ ] | DocObj , key : Key , value : Doc ) {
158158 if ( typeof key === 'number' ) {
159159 assert ( Array . isArray ( container ) , 'Cannot use numerical key for object container' )
160+ assert ( container . length >= key , 'Cannot insert into out of bounds index' )
160161 //container = container.slice()
161162 container . splice ( key , 0 , value )
162163 } else {
Original file line number Diff line number Diff line change @@ -636,6 +636,10 @@ describe('json1', () => {
636636
637637 it ( 'throws if the type is missing' , ( ) =>
638638 assert . throws ( ( ) => type . apply ( { } , [ { et : 'missing' , e : { } } ] ) ) )
639+
640+ it ( 'throws when the op inserts in out of bound index' , ( ) => {
641+ assert . throws ( ( ) => type . apply ( [ 0 ] , [ 2 , { i : 2 } ] ) )
642+ } )
639643 } )
640644
641645 describe ( 'apply path' , ( ) => {
You can’t perform that action at this time.
0 commit comments