@@ -126,20 +126,20 @@ public final class BytevectorLibrary: NativeLibrary {
126126
127127 func bytevectorCopy( _ bvec: Expr , args: Arguments ) throws -> Expr {
128128 let bvector = try bvec. asByteVector ( )
129- guard let ( s, e) = args. optional ( Expr . makeNumber ( bvector . value . count ) ,
130- Expr . makeNumber ( 0 ) ) else {
129+ guard let ( s, e) = args. optional ( Expr . makeNumber ( 0 ) ,
130+ Expr . makeNumber ( bvector . value . count ) ) else {
131131 throw RuntimeError . argumentCount ( of: " bytevector-copy " ,
132- min: 2 ,
133- max: 2 ,
132+ min: 1 ,
133+ max: 3 ,
134134 args: . pair( bvec, . makeList( args) ) )
135135 }
136136 let ( start, end) = ( try s. asInt ( ) , try e. asInt ( ) )
137- guard start >= 0 && start < bvector. value. count else {
137+ guard start >= 0 && start <= bvector. value. count else {
138138 throw RuntimeError . range ( parameter: 2 ,
139139 of: " bytevector-copy " ,
140140 s,
141141 min: 0 ,
142- max: Int64 ( bvector. value. count - 1 ) )
142+ max: Int64 ( bvector. value. count) )
143143 }
144144 guard end >= start && end <= bvector. value. count else {
145145 throw RuntimeError . range ( parameter: 3 ,
@@ -163,18 +163,18 @@ public final class BytevectorLibrary: NativeLibrary {
163163 of: " bytevector-copy! " ,
164164 at,
165165 min: 0 ,
166- max: Int64 ( toVec. value. count - 1 ) )
166+ max: Int64 ( toVec. value. count) )
167167 }
168168 let fromVec = try from. asByteVector ( )
169- guard let ( s, e) = args. optional ( Expr . makeNumber ( fromVec . value . count ) ,
170- Expr . makeNumber ( 0 ) ) else {
169+ guard let ( s, e) = args. optional ( Expr . makeNumber ( 0 ) ,
170+ Expr . makeNumber ( fromVec . value . count ) ) else {
171171 throw RuntimeError . argumentCount ( of: " bytevector-copy! " ,
172172 min: 3 ,
173173 max: 5 ,
174174 args: . pair( to, . pair( at, . pair( from, . makeList( args) ) ) ) )
175175 }
176176 let ( start, end) = ( try s. asInt ( ) , try e. asInt ( ) )
177- guard start >= 0 && start < fromVec. value. count else {
177+ guard start >= 0 && start <= fromVec. value. count else {
178178 throw RuntimeError . range ( parameter: 4 ,
179179 of: " bytevector-copy! " ,
180180 s,
0 commit comments