Restructure comment handling code.#80
Merged
Merged
Conversation
There was an impossibility in error handling where the onCloseTag branch's default (throw Error) statement was impossible. This is because we would always throw in onOpenTag first. We will never see a valid closed tag without an opening. Further, a lone closed tag will fail to parse as a close tag anyway. So this just never happened. One might be tempted to just remove the default in the name of coverage. But the default line actually gives us some value: If we ever add something in open, we might know if we forgot ot add it in close. But that seems like it should be enforced on lint-time or compile-time, not just if we're lucky to exercise a condition. Ideally, we should let the compiler guarantee that any opening tag has a corresponding closing tag. This way, we keep the benefits of this line, and even improve them to become a compile-time property, while changing the closing logic to reflect the impossibility of seeing an unknown closing tag.
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.
There was an impossibility in error handling where the onCloseTag
branch's default (throw Error) statement was impossible. This is because
we would always throw in onOpenTag first. We will never see a valid
closed tag without an opening.
Further, a lone closed tag will fail to parse as a close tag anyway. So
this just never happened.
One might be tempted to just remove the default in the name of coverage.
But the default line actually gives us some value: If we ever add
something in open, we might know if we forgot ot add it in close.
But that seems like it should be enforced on lint-time or compile-time,
not just if we're lucky to exercise a condition. Ideally, we should let
the compiler guarantee that any opening tag has a corresponding closing
tag. This way, we keep the benefits of this line, and even improve them
to become a compile-time property, while changing the closing logic
to reflect the impossibility of seeing an unknown closing tag.