@@ -231,10 +231,8 @@ impl PromiseConstructor {
231
231
) ) ;
232
232
}
233
233
234
- // Get the first argument from the ArgumentsList
235
234
let first_arg = arguments. get ( 0 ) . bind ( gc. nogc ( ) ) ;
236
235
237
- // Try to convert to Array to extract promises
238
236
let Ok ( promise_array) = Array :: try_from ( first_arg. unbind ( ) ) else {
239
237
return Err ( agent. throw_exception_with_static_message (
240
238
ExceptionType :: TypeError ,
@@ -243,7 +241,6 @@ impl PromiseConstructor {
243
241
) ) ;
244
242
} ;
245
243
246
- // Get the first promise from the array
247
244
let array_slice = promise_array. as_slice ( agent) ;
248
245
if array_slice. is_empty ( ) {
249
246
return Err ( agent. throw_exception_with_static_message (
@@ -261,7 +258,6 @@ impl PromiseConstructor {
261
258
) ) ;
262
259
} ;
263
260
264
- // Convert Value to Promise
265
261
let Value :: Promise ( promise_to_await) = first_element. unbind ( ) else {
266
262
return Err ( agent. throw_exception_with_static_message (
267
263
ExceptionType :: TypeError ,
@@ -270,62 +266,12 @@ impl PromiseConstructor {
270
266
) ) ;
271
267
} ;
272
268
273
- // Check if the promise is already settled
274
- if let Some ( result) = promise_to_await. try_get_result ( agent, gc. nogc ( ) ) {
275
- // Promise is already settled, return its result
276
- match result {
277
- Ok ( value) => {
278
- // Create a resolved promise with the value
279
- let result_capability = PromiseCapability :: new ( agent, gc. nogc ( ) ) ;
280
- let result_promise = result_capability. promise ( ) . scope ( agent, gc. nogc ( ) ) ;
281
- result_capability
282
- . unbind ( )
283
- . resolve ( agent, value. unbind ( ) , gc. reborrow ( ) ) ;
284
- return Ok ( result_promise. get ( agent) . into_value ( ) ) ;
285
- }
286
- Err ( error) => {
287
- // Create a rejected promise with the error
288
- return Ok ( Promise :: new_rejected (
289
- agent,
290
- error. value ( ) . unbind ( ) ,
291
- gc. into_nogc ( ) ,
292
- )
293
- . into_value ( ) ) ;
294
- }
295
- }
296
- }
297
-
298
- // Promise is pending, we need to wait for it using await reaction
299
- // Create a promise capability for our result
300
269
let result_capability = PromiseCapability :: new ( agent, gc. nogc ( ) ) ;
301
270
let result_promise = result_capability. promise ( ) . scope ( agent, gc. nogc ( ) ) ;
302
271
303
- // For await reactions, we typically need an async executable and execution context
304
- // Since we're in Promise.all (not an async function), we'll use a simpler approach
305
- // and use regular promise reactions instead of await reactions
306
-
307
- // Use inner_promise_then to wait for the promise
308
- // For simplicity, we'll use Empty handlers which will pass through the value
309
272
let fulfill_handler = PromiseReactionHandler :: Empty ;
310
273
let reject_handler = PromiseReactionHandler :: Empty ;
311
274
312
- // Note: For a real await reaction, you would need:
313
- // 1. An AwaitReactionRecord with execution context and VM state
314
- // 2. A suspended VM that can be resumed
315
- // 3. An async executable (async function or module)
316
-
317
- // Here's how you would create an await reaction (commented out as it requires more setup):
318
- /*
319
- let await_reaction_record = AwaitReactionRecord {
320
- vm: Some(suspended_vm), // Would need a suspended VM
321
- async_executable: Some(AsyncExecutable::AsyncFunction(async_function)), // Would need async function
322
- execution_context: Some(execution_context), // Would need execution context
323
- return_promise_capability: result_capability.clone(),
324
- };
325
- let await_reaction = agent.heap.create(await_reaction_record);
326
- let await_handler = PromiseReactionHandler::Await(await_reaction);
327
- */
328
-
329
275
// For now, let's use a simpler approach that demonstrates the concept
330
276
inner_promise_then (
331
277
agent,
0 commit comments