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

NumberParser failBlock is used inconsistently #9486

Closed
gcotelli opened this issue Jun 17, 2021 · 0 comments · Fixed by #9487
Closed

NumberParser failBlock is used inconsistently #9486

gcotelli opened this issue Jun 17, 2021 · 0 comments · Fixed by #9487

Comments

@gcotelli
Copy link
Member

Bug description
NumberParser includes an instance variable called failBlock. If you look at the references this variable is used inconsistently across the methods. In some methods is evaluated by sending the message value as if it was a block without arguments, and in other methods is evaluated by sending cull:cull:. So currently, if failBlock is configured with a two-argument block and the input given to the parser makes it to use one of the methods sending value it will fail.

To Reproduce
Steps to reproduce the behavior:
Open a Playground and evaluate:

|p|
p := NumberParser new.
p on: '-'.
p failBlock: [ :a :b | ].
p nextInteger

Expected behavior
If two-argument blocks are to be expected (as is suggested by expected: method that provides an error description and the index of the stream), then fail method needs to be updated so two-argument blocks will not fail.

Version information:

  • Pharo Version 9

Expected development cost
Easy to fix. I will propose a PR.

Ducasse pushed a commit that referenced this issue Jun 19, 2021
Improve failBlock usage in NumberParser
Add some test cases
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant