-
Notifications
You must be signed in to change notification settings - Fork 248
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
Improving diagnostics with "Reasons:" and "Suggestions:" #1315
Comments
Some more code:
I personally do not like further overloading parentheses (#542 (comment)). I'm afraid I have mixed two issues in one. |
Oh, but a parenthesized expression is a postfix-expression. //G primary-expression:
//G [...]
//G '(' expression-list ','? ')'
//G [...]
//G
//G postfix-expression:
//G primary-expression
//G [...] So maybe my workaround works unintendedly. |
If you do not use UFCS, it starts to work. https://cpp2.godbolt.org/z/vePsbM7bj It seems that for a regular function call the analysis is not as elaborate. In order to get a better understanding, I would suggest an improved reproducer. E.g. a pure cpp2 case, an object with different functions with different returns, and multiple lines that demonstrate what works and what not works. |
Title: Improving diagnostics with "Reasons:" and "Suggestions:".
Description:
Updating my code, I kept hitting:
cppfront/source/to_cpp1.h
Line 2433 in 68b716a
I'm doubting the usefulness of this error as it is.
It's preventing me from writing
which copies
v
, a vector, into a point fromwindow
tov
.Following the comment a bit above:
cppfront/source/to_cpp1.h
Lines 2411 to 2412 in 68b716a
I parenthesized the expression, which made it it OK.
Can we update these checks?
copy
seems to be as safe as any local variable(https://cpp2.godbolt.org/z/Y8nahPjhh works from Clang 12 and GCC 10 in C++20, to their
HEAD
versions in C++26).in
param
in_ref
.in
param.X()
(expr)
ifparam
is not part of the return value, andin_ref param
otherwise (maybe note thatin
can optimize to pass by copy).copy
param
copy
param.X()
move
param
-> _
, or-> cpp1_rvalue_ref<ParamType>
, or allow-> forward_ref _
and also suggest it.move
param.X()
(expr)
ifparam
is not part of the return value.Sometimes, I'm left wondering the reason for some of the rejections.
It'd be nice to centralize the documentation of how Cpp2 features obsolete guidance.
That would make it easier to challenge some of decisions, and maybe even help notice further improvements.
For example, given the table above:
in
param
in
can optimize to pass by copy. Usein_ref
instead.in
param.X()
param
might live in the resulting value of the expression.copy
param
param
.copy
param.X()
param
.move
param
move
param.X()
param
might live in the resulting value of the expression.In fact, this reminds me of some talk(s) where the speaker(s) mention
how the compilers of other programming languages have much nicer diagnostics.
Something like how those compilers are a friend in the development journey rather than a tool.
Taking all of the above, consider the following Cpp2 code fragment and the contents of a desired diagnostic (https://cpp2.godbolt.org/z/n85qhcjbj).
PS: I don't think this is a [SUGGESTION].
The text was updated successfully, but these errors were encountered: