Normative: make Promise.try use PromiseResolve in non-error case#3883
Open
bakkot wants to merge 1 commit into
Open
Normative: make Promise.try use PromiseResolve in non-error case#3883bakkot wants to merge 1 commit into
bakkot wants to merge 1 commit into
Conversation
|
The rendered spec preview for this PR is available as a single page at https://tc39.es/ecma262/pr/3883 and as multiple pages at https://tc39.es/ecma262/pr/3883/multipage . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Using PromiseResolve differs from the current behavior in that when the argument returns a Promise whose
.constructoris whatever thethisvalue of thePromise.trycall is1, we just return that Promise directly instead of wrapping it in a new one. Otherwise it's exactly the same.This has the advantage of better matching the intuition that this is for cases where you want to write
Promise.resolve(foo())but you also want to wrap sync errors in rejected Promises. Now it actually works exactly likeAs a bonus, it also means this costs zero microtask ticks in the case where the argument is actually an async function, instead of (as currently) two.
See matrix chat 1 2.
Footnotes
Precise check might change. ↩