hex-literal
: ensure '/' as last byte causes error in hex!()
#665
+5
−0
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.
Hello again,
I noticed that, because the way comment exclusion works, having a single forward slash
/
as the last byte given tohex!()
causes no error to be given where there should be one. For instance, the following program compiles without error:Note that this doesn't happen if there are bytes after the
/
(in which a case it errors).My fix adds a check in the implementation of
Iterator
forExcludingComments
for if there are no more bytes and we're in thePotentialComment
state. In this case it simply yields the previous byte (which was the foward slash) so thatnext_hex_val()
will try to parse it as hex and panic with "invalid character". This has the nice property that it's consistent with the error you get currently if a single slash is encountered not at the end of the stream.