@@ -279,6 +279,26 @@ impl TypedArray {
279279 // 4. Return true.
280280 Some ( index)
281281 }
282+
283+ /// Abstract operation `IsTypedArrayFixedLength ( O )`.
284+ ///
285+ /// More information:
286+ /// - [ECMAScript reference][spec]
287+ ///
288+ /// [spec]: https://tc39.es/ecma262/#sec-istypedarrayfixedlength
289+ fn is_fixed_length ( & self ) -> bool {
290+ // 1. If O.[[ArrayLength]] is auto, return false.
291+ if self . is_auto_length ( ) {
292+ return false ;
293+ }
294+
295+ // 2. Let buffer be O.[[ViewedArrayBuffer]].
296+ match self . viewed_array_buffer ( ) . as_buffer ( ) {
297+ // 3. If IsFixedLengthArrayBuffer(buffer) is false and IsSharedArrayBuffer(buffer) is false, return false.
298+ BufferRef :: Buffer ( buf) => buf. is_fixed_len ( ) ,
299+ BufferRef :: SharedBuffer ( _) => true ,
300+ }
301+ }
282302}
283303
284304// Integer-Indexed Exotic Objects [[PreventExtensions]] ( O )
@@ -290,39 +310,22 @@ pub(crate) fn typed_array_exotic_prevent_extensions(
290310 obj : & JsObject ,
291311 context : & mut Context ,
292312) -> JsResult < bool > {
293- // 1. If IsTypedArrayFixedLength(O) is false, return false.
294- if !is_typed_array_fixed_length ( obj) ? {
295- return Ok ( false ) ;
296- }
297-
298- // 2. Return OrdinaryPreventExtensions(O).
299- ordinary_prevent_extensions ( obj, context)
300- }
301-
302- /// Abstract operation `IsTypedArrayFixedLength ( O )`.
303- ///
304- /// More information:
305- /// - [ECMAScript reference][spec]
306- ///
307- /// [spec]: https://tc39.es/ecma262/#sec-istypedarrayfixedlength
308- fn is_typed_array_fixed_length ( obj : & JsObject ) -> JsResult < bool > {
309- let ta = obj
313+ let is_fixed_length = {
314+ let ta = obj
310315 . downcast_ref :: < TypedArray > ( )
311316 . js_expect ( "must be a TypedArray" ) ?;
312317
313- // 1. If O.[[ArrayLength]] is auto, return false.
314- if ta. is_auto_length ( ) {
318+ ta. is_fixed_length ( )
319+ } ; // Note: this block ensures that the borrow of obj is dropped
320+ // so it may be re-borrowed in step 3
321+
322+ // 1. If IsTypedArrayFixedLength(O) is false, return false.
323+ if !is_fixed_length {
315324 return Ok ( false ) ;
316325 }
317326
318- // 2. Let buffer be O.[[ViewedArrayBuffer]].
319- let is_fixed_length = match ta. viewed_array_buffer ( ) . as_buffer ( ) {
320- // 3. If IsFixedLengthArrayBuffer(buffer) is false and IsSharedArrayBuffer(buffer) is false, return false.
321- BufferRef :: Buffer ( buf) => buf. is_fixed_len ( ) ,
322- BufferRef :: SharedBuffer ( _) => true ,
323- } ;
324-
325- Ok ( is_fixed_length)
327+ // 2. Return OrdinaryPreventExtensions(O).
328+ ordinary_prevent_extensions ( obj, context)
326329}
327330
328331/// `CanonicalNumericIndexString ( argument )`
0 commit comments