-
Notifications
You must be signed in to change notification settings - Fork 266
Fix unpublished comments ICE error #351
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 unpublished comments ICE error #351
Conversation
Fix parsing of the following code:
```cpp
a: type = { } // a
i : int = 42;
```
The current implementation fail with ICE. After this change works and generate correct code.
Only one test change behaviour (due to lack of new line on the end of class definition):
```patch
diff --git a/regression-tests/test-results/pure2-types-order-independence-and-nesting.cpp b/regression-tests/test-results/pure2-types-order-independence-and-nesting.cpp
index 9449c2a..5ace9c1 100644
--- a/regression-tests/test-results/pure2-types-order-independence-and-nesting.cpp
+++ b/regression-tests/test-results/pure2-types-order-independence-and-nesting.cpp
@@ -69,8 +69,8 @@ namespace M {
template<typename T, typename U> class A {
public: template<int I> class B {
public: template<typename V, int J, typename W> static auto f(W const& w) -> void;
-public: B() = default; B(B const&) = delete; auto operator=(B const&) -> void = delete; };
-public: A() = default; A(A const&) = delete; auto operator=(A const&) -> void = delete; };
+public: B() = default; B(B const&) = delete; auto operator=(B const&) -> void = delete; };public: A() = default; A(A const&) = delete; auto operator=(A const&) -> void = delete;
+};
}
```
The current implementation of cppfront ends with ICE
when parsing the following code:
```cpp
a: namespace = { } // a
i : int = 42;
```
After this change code is parsed and cppfront generates correct code.
|
Thank you. I still get it on this: Still ICEsThe last line suffices for the ICE: |
|
@JohelEGP yes, I have noticed that. I am looking for a fix. |
|
#344 is not fixed by this PR (I fixed two other issues) - more description about the original issue here: #344 (comment) |
|
Thanks! BTW I made that comment check such a noisy ICE because it's super important to me to never drop anything the programmer wrote, including (or even especially?) comments. Thanks for looking into this. |
|
Thanks for the bug reports and repros! These should all work now, fixed as a separate commit (see commit message), please check... and I did take the part of the suggested PRs which was to do the extra finalizing at the end of each section (not just at the very end of the file). 🙏 |
|
Checking... |
|
I confirm that it works on my tests as well. |
…loses hsutter#351, closes hsutter#354 Thanks for these test cases. The common issue was that occasionally an emitted piece of Cpp1 contained a newline character, which was not accounted for in the code that did comment merging. Thanks also for the PRs for proposed fixes. I looked at those too and tried them out. In the end, I found that what worked best and most generally was to break apart strings that contain newlines into one chunk per line, and this allowed the comment merging to happen correctly by avoiding the hidden-to-the-comment-merger line change. So this commit is going with that solution rather than the other proposed PRs, but the other PRs helped find this root cause and shed light on a general solution, as did the test cases. Thanks again for both!
In the current implementation of cppfront (f83ca9b), the following code:
a: type = { } // a i : int = 42;or
End with ICE
not all comments were printederror.This change removes extra new-line printed after namespace or UDT definition that solves this issue.
All regression tests pass (except for two files impacted by missing newlines - updated in this PR).