Conversation
A try that is the last statement of a function now emits as a statement whose branches return their values, instead of an arrow IIFE created and called on every invocation. The value form keeps its wrapper for true expression positions such as `x = try ...`, where there is no function to return from. Values are identical: the wrapper only turned each branch's last expression into a return, and the statement form does the same in place. `this` and `arguments` were already preserved by the arrow. An async tail try loses the async wrapper and its extra await; a generator may now yield inside a tail try, which the wrapper rejected. Of 130 tail-position tries across packages and src, every one now emits in place; the 28 wrappers that remain are assignments. Corpus: lowerings.js changes one site, three lines, from the wrapper to the statement; 184 artifacts unchanged. The parser is untouched. The browser bundle is regenerated under the pinned Bun. Battery: twelve rows in errors.rip pin the body and handler values, the handler-less form, finally ordering, an explicit inner return, a catch pattern, a try after other statements, yield and await inside, and the emitted code for the tail, async and value forms. Two sweep rows that pinned the wrapper shape now pin the statement.
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.
Summary
A
trythat is the last statement of a function now emits as a statement whose branchesreturntheir values. It used to be wrapped in an arrow IIFE, created and called on every invocation:The value form keeps its wrapper in true expression positions such as
x = try ..., where there is no function to return from.Same values. The wrapper only turned each branch's last expression into a
return; the statement form does that in place.thisandargumentswere already preserved by the arrow.finallyruns after the return either way.Two things improve. An async tail
trydrops the async wrapper and the extraawaitaround it. A generator may nowyieldinside a tailtry, which the wrapper rejected.Reach. 130 tail-position tries across
packagesandsrcnow emit in place, 27 of them in the sites manager. The 28 wrappers that remain are all assignments.Artifacts.
lowerings.jschanges one site, three lines; 184 corpus artifacts unchanged; parser untouched; browser bundle regenerated under Bun 1.4.0.Test
Twelve new rows in
errors.rip; twosweep.riprows that pinned the wrapper now pin the statement. Language battery 3270 passing, toolchain gates 661 passing, fulltest:allsuite green across all 26 lanes.