Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid implicit return when block guarantees exit #1211

Merged
merged 1 commit into from
May 3, 2024
Merged

Conversation

edemaine
Copy link
Collaborator

@edemaine edemaine commented May 3, 2024

Motivation: Avoiding the following:

; // avoid implicit return of hoisted function

This function has a return up top, then defines some hoisted functions. Without this semicolon, the last function gets a return before it. Hence the semicolon to avoid this.

All this seems ugly. Instead we can turn off implicit return if there is a guaranteed return or other exit earlier in the same block. We already have isExit to detect this, so this amounts to a one-line check.

@edemaine edemaine merged commit f21c3c9 into main May 3, 2024
2 of 3 checks passed
@edemaine edemaine deleted the exit-no-return branch May 3, 2024 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants