@@ -335,39 +335,39 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayConstructor::from_async)
335
335
using_sync_iterator = TRY (async_items.get_method (vm, vm.well_known_symbol_iterator ()));
336
336
}
337
337
338
- GCPtr<Object> array;
339
-
340
- // e. If IsConstructor(C) is true, then
341
- if (constructor.is_constructor ()) {
342
- // i. Let A be ? Construct(C).
343
- array = TRY (JS::construct (vm, constructor.as_function ()));
344
- }
345
- // f. Else,
346
- else {
347
- // i. Let A be ! ArrayCreate(0).
348
- array = MUST (Array::create (realm, 0 ));
349
- }
350
-
351
- // g. Let iteratorRecord be undefined.
338
+ // e. Let iteratorRecord be undefined.
352
339
Optional<IteratorRecord> iterator_record;
353
340
354
- // h . If usingAsyncIterator is not undefined, then
341
+ // f . If usingAsyncIterator is not undefined, then
355
342
if (using_async_iterator) {
356
343
// i. Set iteratorRecord to ? GetIterator(asyncItems, async, usingAsyncIterator).
357
344
// FIXME: The Array.from proposal is out of date - it should be using GetIteratorFromMethod.
358
345
iterator_record = TRY (get_iterator_from_method (vm, async_items, *using_async_iterator));
359
346
}
360
- // i . Else if usingSyncIterator is not undefined, then
347
+ // g . Else if usingSyncIterator is not undefined, then
361
348
else if (using_sync_iterator) {
362
349
// i. Set iteratorRecord to ? CreateAsyncFromSyncIterator(GetIterator(asyncItems, sync, usingSyncIterator)).
363
350
// FIXME: The Array.from proposal is out of date - it should be using GetIteratorFromMethod.
364
351
iterator_record = create_async_from_sync_iterator (vm, TRY (get_iterator_from_method (vm, async_items, *using_sync_iterator)));
365
352
}
366
353
367
- // j . If iteratorRecord is not undefined, then
354
+ // h . If iteratorRecord is not undefined, then
368
355
if (iterator_record.has_value ()) {
369
- // i. Let k be 0.
370
- // ii. Repeat,
356
+ GCPtr<Object> array;
357
+
358
+ // i. If IsConstructor(C) is true, then
359
+ if (constructor.is_constructor ()) {
360
+ // 1. Let A be ? Construct(C).
361
+ array = TRY (JS::construct (vm, constructor.as_function ()));
362
+ }
363
+ // ii. Else,
364
+ else {
365
+ // i. Let A be ! ArrayCreate(0).
366
+ array = MUST (Array::create (realm, 0 ));
367
+ }
368
+
369
+ // iii. Let k be 0.
370
+ // iv. Repeat,
371
371
for (size_t k = 0 ;; ++k) {
372
372
// 1. If k ≥ 2^53 - 1, then
373
373
if (k >= MAX_ARRAY_LIKE_INDEX) {
@@ -471,6 +471,8 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayConstructor::from_async)
471
471
// iii. Let len be ? LengthOfArrayLike(arrayLike).
472
472
auto length = TRY (length_of_array_like (vm, array_like));
473
473
474
+ GCPtr<Object> array;
475
+
474
476
// iv. If IsConstructor(C) is true, then
475
477
if (constructor.is_constructor ()) {
476
478
// 1. Let A be ? Construct(C, « 𝔽(len) »).
0 commit comments