-
Notifications
You must be signed in to change notification settings - Fork 274
Include function and parameter in convert_function
error messages
#6426
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
Include function and parameter in convert_function
error messages
#6426
Conversation
const size_t ERROR_MSG_LEN = 512; | ||
char parameter_error_message[ERROR_MSG_LEN]; | ||
// we have a body, make sure all parameter names are valid | ||
for(const auto &p : f.parameter_identifiers) | ||
{ | ||
DATA_INVARIANT(!p.empty(), "parameter identifier should not be empty"); | ||
if (p.empty()) | ||
{ | ||
snprintf(parameter_error_message, | ||
ERROR_MSG_LEN - 1, | ||
"parameter identifier should not be empty\n" | ||
"function: %s\n" | ||
"parameter: %s", | ||
identifier.c_str(), | ||
p.c_str()); | ||
} | ||
DATA_INVARIANT(!p.empty(), parameter_error_message); | ||
|
||
if (!symbol_table.has_symbol(p)) | ||
{ | ||
snprintf(parameter_error_message, | ||
ERROR_MSG_LEN - 1, | ||
"parameter identifier must be a known symbol\n" | ||
"function: %s\n" | ||
"parameter: %s", | ||
identifier.c_str(), | ||
p.c_str()); | ||
} | ||
DATA_INVARIANT( | ||
symbol_table.has_symbol(p), | ||
"parameter identifier must be a known symbol"); | ||
parameter_error_message); |
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.
I'm not sure that defining and constructing all of this outside the invariant is the right choice. There is also DATA_INVARIANT_WITH_DIAGNOSTICS
that handles other arguments beyond the message.
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.
Yes; what @TGWDB says.
Codecov Report
@@ Coverage Diff @@
## develop #6426 +/- ##
===========================================
- Coverage 76.04% 76.01% -0.04%
===========================================
Files 1546 1527 -19
Lines 165541 164465 -1076
===========================================
- Hits 125882 125013 -869
+ Misses 39659 39452 -207
Continue to review full report at Codecov.
|
6063df6
to
5506b3d
Compare
Hi @TGWDB , thanks for your suggestion! I have changed the code to use |
5506b3d
to
c11b5cd
Compare
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.
Yes; looks good.
Please forgive the pedantry but in future it would be easier if this was two separate PRs. That way each PR does / fixes one thing. I realise this is hassle.
identifier, | ||
"parameter:", | ||
p); | ||
|
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.
That doesn't make sense: when the message is triggered, p
is empty. Thus, why log it?
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.
Right. Removed p
from this case.
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.
@adpaco-aws Could you please squash the three commits pertaining to the diagnostic message into a single one?
3078d8a
to
21680ba
Compare
@tautschnig just squashed them and rebased against develop, let me know if you see any issues. |
Include the name of the function and parameter causing
DATA_INVARIANT
to fail in the error messages. This saves time spent in debugging which function and parameter are problematic.Fixes a couple of mistakes I spotted in the section titles in
COMPILING.md
.