Fix an error message StartsWith parser throws #332
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.
The Problem
StartsWith parser don't produce an error message as documented when failed.
Above code produce a below error message which has a wired type presented at expected value position.
Causes
StartsWith parser hold possiblePrefix value as AnyCollection type, so it would lose its original type.
It could be problematic when the possiblePrefix value was passed as argument to formatting function, because formatting function dosen't handle AnyCollection type as its input type. It only cares about String related type so type erased AnyCollection will be always formatted as it's own Type name.
Fixs
Alternatives