-
Notifications
You must be signed in to change notification settings - Fork 161
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
X3 3.0.10 error_handler where() is wrong #712
Comments
This is a breaking change if the behavior changed. @Kojoley, do you have an idea which commit this happened? This will break a lot of code. |
Most likely, removal of whitespace trimming (#670).
I don't think so, it is a diagnostic message for humans. There are fundamental design choices that are conflicting: 1) sequence parser rolls back the iterator 2) error handler does not have a context to grab a skipper to skip whitespaces, but even if it had, that would be wrong because of I checked the idea from #704
and it does solve the issue for |
OK, well, at least fix the examples, so they show how this behavior is 'properly' implemented and provide warnings of the breaking change in the comments, perhaps. |
The change in behaviour of the sequence parser also affects other examples which rely on I am using @djowel is there a set of policy statatements or design goals that could make it easier to make certain design choices like this? |
In retrospect, I think this change is a mistake. To be honest, I am lost on the details about the rationale for this change, looking at #670 and #704. I still think this will break a lot of code that relies on it. @Kojoley has his reasons. I am hoping he could explain more about the justifications for the change, esp. WRT "an idea about rich and low overhead error reporting" mentioned in #704. |
What change? You have not reported that and I am not aware of behavior changes in the sequence parser.
Hmm, this one is caused by the change to rules, though the same issue applies - because the actual skipping is done in primitive parsers it is not possible to redo the skipping correctly in rules due to
As you may see in #546 report, different people have different needs and blindly skipping whitespaces is not working for everyone. However, in fixing #546 there was no goal to change the behavior for the example. I do try my best to check examples to not regress, but I mainly rely on the test suit which cannot catch everything because it is also manually populated either when I spot something to be undertested or when I fix something. You can make you own handler with wanted behavior and use it even now, either based on
I am working on preparing changes needed to fix error_handling.cpp example for the review, please don't rush me. |
@syyyr I am sorry for disturbing you. May I ask you to tell how is important for you to be able to use |
I don't think it is very important to me, I suppose I could refactor with some sort of a dummy rule to the left of the no_skip? The only real reason that I need no_skip there is because a long time ago, I decided I'm going to use phrase_parse. I've been thinking of refactoring my code to use x3::parse (and use skip directives where needed), because that's what suits my program better. tl;dr: No, it is not important to me. |
FWIW, I have full confidence in @Kojoley. I just want to make sure the changes do not cause any confusion and lots of headache in having to readjust code that now silently behaves differently. Foremost, the examples should be fixed. |
@syyyr most logical refactor is to lift |
An aside: this is my bad:
Which I incorrectly interpretted as a possible explanation for the observed change in behaviour of
Sorry. Please disregard this statement. |
@djowel wrote:
@Kojoley you also have my backing. I just think that resolving "fundamental design choices that are conflicting" is a particularly difficult challenge which I do not envy. I offer any help I can to help resolve this issue.
|
I would appreciate if you test a solution prototype https://github.com/Kojoley/spirit/tree/x3-remove-roll-back-from-sequence-parser, the branch should fix both issues you have reported. |
@Kojoley I have started to look at your solution prototype and have come across some things which I was not expecting. The first is in the tutorial
In previous versions, the sequence "(1,)" was a parse failure. If I change the sequence operator ">>" to the expectation operator ">", then that fails. Looking at the grammar, I think this case should be a failure. FYI the output of my regression test suite is:
|
Thanks for the catch, I pushed the fix into the branch. |
@Kojoley your latest push fixes the |
I have another example of some unexpected behaviour. This is based on code you supplied when exploring #679
which produces the following error at compile time:
I am still not very good at interpretting error messages of this ilk. What is going on, and is this what you would expect? |
The changes in the branch cannot cause compile error, they may only introduce runtime bugs. The code doesn't compile before the changes https://godbolt.org/z/M5KMsnobG and I don't think it should because |
I'm puzzled. The link https://godbolt.org/z/M5KMsnobG points to the code I supplied above, and I see that you get the same compile time error. You said
But the code I supplied does compile on a machine with these versions:
I'm not familiar with This line of code does compile for 0x3008 but not for 0x3010. I am not saying that this failure to compile has anything to do with the code in your fixes for #679 and this #712, but something has been introduced between 0x3008 and 0x3010 that causes the failure. I am unable to interpret the compile time error messaging. I do not see how changing Please could you help explain what is going on here. |
It only confirms that it is not related to the changes we are discussing here.
using Qaz = std::vector<boost::variant<int>>;
using Foo = std::vector<boost::variant<Qaz, int>>;
using Bar = std::vector<boost::variant<Foo, int>>;
Bar x;
x.emplace_back(Qaz{}); |
Oh, (slightly embarrassed), It leaves a potentially awkward question of why
ever did compile. But that is now fixed, and not relevant to this ticket. |
I am still trawling through all of my code, unwinding various workarounds. This code does not compile.
I think it should complie (as in I cannot see why it should not). Is this related, or should a separate issue be raised? |
File a new issue for it (not a regression and not related to this one). |
@Kojoley I have now gone through as much of my code as I care to at the present time and unwound various workarounds for this issue. My code is a whole lot cleaner now. Thanks. I have raised separate issues for the remaining few issues I face. From a purely coding perspective, I am happy with your fix.
Please could you point me at the documentation changes and the "version history" inserts that you intend to apply, so that I can also review those. |
I run into the same issue, probably. My test cases fail with diagnostic message for humans (line_start and position self (shows a space on begin of token)). |
- applied "Fix: annotate_on_success doesn't annotate variant" cba529383accfcf96027ddeb2fd70cd522cd97fb from https://github.com/boostorg/spirit - Error location test verification test_vhdl_syntax failed with boost 1.78; probably run into [X3 3.0.10 error_handler where() is wrong #712](boostorg/spirit#712).
- affected by [X3 3.0.10 error_handler where() is wrong #712]( boostorg/spirit#712), also [X3: error_handler should not skip whitespaces #670]( boostorg/spirit#670) hence some test will fail - TBD testbench for error formatted printing - discard operator() overloads for diagnostic_handler, using named member function to express the issue - fix some naming issues - moved line_column_number(), get_line_start(), current_line() from position_cache to diagnostic_handler which generates the output - add own classes for handling and formatted printing of error messages - adapt position_cache_test_{1,2}.cpp (basically removed stuff which is moved into new classes diagnostic_{handler, printer, context}
The position returned by the error_handler where() points to the last successful parse point, not the beginning of the failure. Hence the error messaging is not very meaningful and does not match the expected results in the tutorial.
Using the code from
https://www.boost.org/doc/libs/1_78_0/libs/spirit/doc/x3/html/spirit_x3/tutorials/error_handling.html
Using spirit X3 3.0.8, and in the tutorial documentation:
Using spirit X3 3.0.10:
The text was updated successfully, but these errors were encountered: