-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Parser refactor. #2297
Parser refactor. #2297
Conversation
One sad thing is that the clippy warning make CI red is removed in currently nightly clippy but we have to deal with it in 1.46.0. :-P rust-lang/rust-clippy#6313 |
0f96e77
to
a960852
Compare
This also fixes #2229, add tests later. Edit: |
d60981b
to
6d52174
Compare
Hmm, sorry this PR is a bit long... The reason it because I need to prove that this refactor makes it easy for future bug solving and feature implementing, which I prove it in the last few commits. But it make this PR hard to review. I'll seperate it into several commits later. |
c45741c
to
f890ef8
Compare
Do you have a solution for #1794 on top of this parser refactor? I don't want to revert the fix without any other fix. |
But that's a fragile fix(I don't think it's a fix actually). I showed you the bad case in that issue comment. The inner detail is that the parser is using a positional counter to determine which positional argument should take current value. And also, the group validation is processed after all parsing is done. This is the reason of #1794, the parser cannot access arg group info in the parsing stage so it puts the value in Now let's look at how #1856 fix this. It introduces the Do you notice the problem? It just increases the positional counter rather than effectively avoiding the parser pushing value to the sibling positional args or stealing already pushed value from sibling positioal args. Which causes the problem I pointed in the issue comment, just with a little change to the test case, this kind of hacky workaround will fail. This is the design problem, and won't have an easy fix until the parser have the ability to steal the value from an arg to another, which needs a redesign of our parser. And the problem will only occur when a user groups a flag with positional argument. I don't like reverting fixes either, but I have to :
Hope you understand... |
Okay, but do you have an idea (even though it's not implemented yet) on how to fix it and are going to work it on soon? |
@pksunkara There are several options on fixing this. For example, we can push all of the parsed positional values to a vector and pushing them to each positional arguments at last(there are more details). Another option is validating on each parsing stage, and rollback on parsing failure. |
912602a
to
4d8480f
Compare
I don't think the last commit needs to be in this PR. Please make a separate one once this is merged. |
Oh, so first #2320? I thought this was first. Got it. |
c4ba1f7
to
a6b2501
Compare
Ok, these are last bits(hard to be split) @pksunkara |
Aren't the last 2 commits for different things? |
It seems that only the last commit is for different thing(previous commits are all doing one thing: grouped values). The last commit is based on previous commits, and also it's acceptable if previous commits is acceptable. So seperating out it is not that meaningful. |
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.
Looks good. I guess users would need grouped_values_of
only when they have both MultipleValues
and MultipleOccurrences
turned on, right?
Maybe we should have a better name for that?
Fix clippy type complexity fix
A little parser refactor.
Fixes #1026, check
tests/grouped_values.rs
for the results.Fixes #1374, check
tests/grouped_values.rs:issue_1374()
.Fixes #2171, check
tests/grouped_values.rs:issue_2171()
.