Skip to content

Replace impossible error conditions with debug assertions#169

Open
apasel422 wants to merge 4 commits intoundef1nd:mainfrom
apasel422:assert
Open

Replace impossible error conditions with debug assertions#169
apasel422 wants to merge 4 commits intoundef1nd:mainfrom
apasel422:assert

Conversation

@apasel422
Copy link
Collaborator

These conditions are only possible when the individual bare-item parsing
methods are called directly, but that is only possible in tests.

@apasel422 apasel422 marked this pull request as ready for review March 31, 2025 12:43
@apasel422 apasel422 requested a review from valenting April 1, 2025 12:28
@apasel422 apasel422 requested a review from undef1nd April 15, 2025 12:44
Copy link
Collaborator

@valenting valenting left a comment

Choose a reason for hiding this comment

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

As I mentioned in a previous PR, I'm not sure we ought to replace these checks with debug asserts. These don't run in production, and leave space for obscure bugs to creep in.

@apasel422
Copy link
Collaborator Author

As I mentioned in a previous PR, I'm not sure we ought to replace these checks with debug asserts. These don't run in production, and leave space for obscure bugs to creep in.

If these methods were inlined into their lone caller, these error conditions would clearly be impossible. We could do that instead, guaranteeing that this code cannot be reached without the proper precondition. IMO these non-public methods only exist for readability, not because we expect them to gain any other callers in the future.

These conditions are only possible when the individual bare-item parsing
methods are called directly, but that is only possible in tests.
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