Skip to content

feat(assert): optional reason param for unreachable (#4404) #4405

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

Merged
merged 1 commit into from
Feb 28, 2024

Conversation

lionel-rowe
Copy link
Contributor

Fixes #4404

@lionel-rowe lionel-rowe requested a review from kt3k as a code owner February 27, 2024 12:14
Copy link
Contributor

@iuioiua iuioiua left a comment

Choose a reason for hiding this comment

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

LGTM! I'm for the idea. I'll let Yoshiya review it, too. This does make me wonder whether we should introduce an UnreachableError class that extends AssertionError. Not a strong idea, though.

@@ -11,6 +11,6 @@ import { AssertionError } from "./assertion_error.ts";
* unreachable(); // Throws
* ```
*/
export function unreachable(): never {
throw new AssertionError("unreachable");
export function unreachable(reason?: string): never {
Copy link
Contributor

Choose a reason for hiding this comment

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

We usually use the msg argument name in std/assert. Though, how this is now might be fine.

Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

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

The suggestion seems reasonable to me. LGTM

@iuioiua iuioiua merged commit 0a5f52b into denoland:main Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

suggestion: optional reason param for assert::unreachable
3 participants