|
| 1 | +// This file was procedurally generated from the following sources: |
| 2 | +// - src/dynamic-import/import-defer-specifier-tostring-abrupt-rejects.case |
| 3 | +// - src/dynamic-import/catch/nested-async-arrow-fn-return-await.template |
| 4 | +/*--- |
| 5 | +description: Abrupt from ToString(specifier) rejects the promise (nested in async arrow function, returned) |
| 6 | +esid: sec-import-call-runtime-semantics-evaluation |
| 7 | +features: [import-defer, dynamic-import] |
| 8 | +flags: [generated, async] |
| 9 | +info: | |
| 10 | + ImportCall : |
| 11 | + import( AssignmentExpression ) |
| 12 | +
|
| 13 | + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). |
| 14 | + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). |
| 15 | + 3. Let argRef be the result of evaluating AssignmentExpression. |
| 16 | + 4. Let specifier be ? GetValue(argRef). |
| 17 | + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). |
| 18 | + 6. Let specifierString be ToString(specifier). |
| 19 | + 7. IfAbruptRejectPromise(specifierString, promiseCapability). |
| 20 | + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). |
| 21 | + 9. Return promiseCapability.[[Promise]]. |
| 22 | +
|
| 23 | +
|
| 24 | + Import Calls |
| 25 | +
|
| 26 | + Runtime Semantics: Evaluation |
| 27 | +
|
| 28 | + ImportCall : import . defer ( |AssignmentExpression| ) |
| 29 | + 1. Return ? EvaluateImportCall(|AssignmentExpression|, ~defer~) |
| 30 | +
|
| 31 | + EvaluateImportCall ( specifierExpression, phase ) |
| 32 | + 1. Let _referrer_ be GetActiveScriptOrModule(). |
| 33 | + 1. If _referrer_ is *null*, set _referrer_ to the current Realm Record. |
| 34 | + 1. Let _specifierRef_ be ? Evaluation of _specifierExpression_. |
| 35 | + 1. Let _specifier_ be ? GetValue(_specifierRef_). |
| 36 | + 1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%). |
| 37 | + 1. Let _specifierString_ be Completion(ToString(_specifier_)). |
| 38 | + 1. IfAbruptRejectPromise(_specifierString_, _promiseCapability_). |
| 39 | + ... |
| 40 | +
|
| 41 | +---*/ |
| 42 | +const obj = { |
| 43 | + toString() { |
| 44 | + throw 'custom error'; |
| 45 | + } |
| 46 | +}; |
| 47 | + |
| 48 | + |
| 49 | +const f = async () => await import.defer(obj); |
| 50 | + |
| 51 | +f().catch(error => { |
| 52 | + |
| 53 | + assert.sameValue(error, 'custom error'); |
| 54 | + |
| 55 | +}).then($DONE, $DONE); |
0 commit comments