-
Notifications
You must be signed in to change notification settings - Fork 261
[BUG] Non-empty line after one-liner type with requires clause fails assertion #472
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
Comments
I have an easy fix for the assertion: diff --git a/source/cppfront.cpp b/source/cppfront.cpp
index 5b89964..44cc52e 100644
--- a/source/cppfront.cpp
+++ b/source/cppfront.cpp
@@ -5094,7 +5094,7 @@ public:
if (n.requires_clause_expression) {
printer.print_cpp2("requires( ", n.requires_pos);
emit(*n.requires_clause_expression);
- printer.print_cpp2(" )\n\n", n.requires_pos);
+ printer.print_cpp2(" )\n", n.requires_pos);
}
printer.print_cpp2("class ", n.position()); But even without the parsing error, the result cpp1 code is not good (check here: https://cpp2.godbolt.org/z/eGMMz8Txj) #include "cpp2util.h"
requires( true )
class t;
requires( true )
class t {
public: t() = default;
public: t(t const&) = delete; /* No 'that' constructor, suppress copy */
public: auto operator=(t const&) -> void = delete;
};
auto main() -> int;
auto main() -> int{} error:
|
Hmmm... yes. |
The most probably requires clause for non-templates should be a cpp2 parsing error. |
That's actually a Cpp1 semantic rule |
Thanks! |
Re elevating the Cpp1 semantic rule to Cpp2, repeating rationale from #528 for visibility: I do think there's value in diagnosing a Rationale:
So diagnosing the type case in Cpp2 delivers the primary diagnostic usability improvement. |
Title: Non-empty line after one-liner type with requires clause fails assertion.
Minimal reproducer (https://cpp2.godbolt.org/z/bfh5bfTj4):
Commands:
Actual result and error:
Output.
The text was updated successfully, but these errors were encountered: