Skip to content

Conversation

@josephsavona
Copy link
Member

@josephsavona josephsavona commented Jan 22, 2026

Control-flow expressions such as logicals, optionals, and ternaries were not supported within try/catch. BuildReactiveFunction recursively traversed these terminals, and was not expecting their condition blocks to end in a maybe-throw terminal, which can occur due to the try/catch. The fix here is to treat the maybe-throw similarly to goto, passing through to the continuation block.

I added some more tests and realized this has issues, still iterating

@josephsavona josephsavona requested review from mofeiZ and poteto January 22, 2026 22:56
@meta-cla meta-cla bot added the CLA Signed label Jan 22, 2026
@github-actions github-actions bot added the React Core Team Opened by a member of the React Core Team label Jan 22, 2026
@josephsavona josephsavona marked this pull request as draft January 23, 2026 00:16
@josephsavona josephsavona changed the title [compiler] Support optional/logical/etc within try/catch [wip][compiler] Support optional/logical/etc within try/catch Jan 23, 2026
@josephsavona josephsavona force-pushed the worktree-2026-01-22-11-41-02-orange-river branch 2 times, most recently from ffa4d6e to 79e188d Compare January 24, 2026 00:07
{obj: {method: () => 'different'}},
{obj: {method: null}},
{obj: {notMethod: true}},
{obj: null},
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs a variant that throws. maybe obj?.method?.(obj.foo) so that this throws if obj == null

{a: null, b: null, c: 'third'},
{a: undefined, b: undefined, c: 'fallback'},
{a: 0, b: 'not zero', c: 'third'},
{a: '', b: 'not empty', c: 'third'},
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a variant that throws: replace ?? c with ?? throwError(c)

@josephsavona josephsavona force-pushed the worktree-2026-01-22-11-41-02-orange-river branch from 79e188d to 20c7514 Compare January 24, 2026 00:34
Control-flow expressions such as logicals, optionals, and ternaries were not supported within try/catch. BuildReactiveFunction recursively traversed these terminals, and was not expecting their condition blocks to end in a maybe-throw terminal, which can occur due to the try/catch. The fix here is to treat the maybe-throw similarly to goto, passing through to the continuation block.
@josephsavona josephsavona force-pushed the worktree-2026-01-22-11-41-02-orange-river branch from 20c7514 to b58f60f Compare January 24, 2026 00:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant