Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix an error message StartsWith parser throws #332

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

pinkjuice66
Copy link
Contributor

@pinkjuice66 pinkjuice66 commented Dec 5, 2023

The Problem

StartsWith parser don't produce an error message as documented when failed.

스크린샷 2023-12-06 오전 1 52 04

Above code produce a below error message which has a wired type presented at expected value position.
스크린샷 2023-12-06 오전 1 49 05

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

  • Holds possiblePrefix value with Any type, so it can preserve it's own type and pass it when we need to format that value.

Alternatives

  • Add new generic 'PossiblePrefix' to StartsWith
    • It will add more complexity to whole StartsWith type.
  • Let formatting function handle AnyCollection Type as its input.
    • We should handle other edge cases like when our original intention was to leave it as it is but AnyCollection with UInt8 Element unexpectedly converts to String.

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.

None yet

1 participant