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 a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this parse is justified. At the least we should have
parse_whitespaces
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This array type parser is called by the plaintext type parser, which expects whitespace to have been skipped over already: the other two alternative parsers for plaintext type, namely literal type and identifier, do not skip over whitespace.
This is an instance of a general pattern in the Aleo instructions parser:
Plaintext types, including array types, belong to the second group of constructs above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see your perspective, we should make sure its parent callers have some notion of
parse_whitespace
since we don't invokestring.trim()
before calling the parser.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, definitely. I believe that to be the case. I don't have a formal proof yet, but here's an argument. As you may know, I've derived the ABNF grammar of Aleo instructions directly from the parser. So under the (good) assumption that the grammar is consistent with the parser, we can see the following in the grammar:
plaintext-type
not at the start of the right side of a rule is preceded byws
, which corresponds toSanitizer::parse_whitespaces
.plainttext-type
occurs at the start of the right sides ofvalue-type
,mapping-type
,finalize-type
, andentry-type
.value-type
, ...,entry-type
, recursively, and find that there is always a precedingws
.(That was actually a sketch of a formal proof.)