-
Notifications
You must be signed in to change notification settings - Fork 90
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
Avoid exception in Options when parsing string to Field #2457
Conversation
Mostly annoying with debugging, if an expected exception is thrown.
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.
clang-tidy made some suggestions
src/sys/options.cxx
Outdated
return FieldFactory::get()->create3D(bout::utils::get<std::string>(value), this, | ||
similar_to.getMesh(), similar_to.getLocation()); | ||
} else if (bout::utils::holds_alternative<Tensor<BoutReal>>(value)) { | ||
auto localmesh = similar_to.getMesh(); |
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.
warning: auto localmesh
can be declared as auto *localmesh
[readability-qualified-auto]
auto localmesh = similar_to.getMesh();
^
note: this fix will not be applied because it overlaps with another fix
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 am wondering about this one - wouldn't it increase readability even more if this would be Mesh*
rather than auto*
?
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, you're probably right -- this bit isn't generic, the type isn't already repeated on the left, and we're unlikely to change the type, so Mesh*
is probably good
src/sys/options.cxx
Outdated
similar_to.getMesh(), similar_to.getLocation()); | ||
} else if (bout::utils::holds_alternative<Tensor<BoutReal>>(value)) { | ||
auto localmesh = similar_to.getMesh(); | ||
if (!localmesh) { |
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.
warning: implicit conversion Mesh *
-> bool [readability-implicit-bool-conversion]
if (!localmesh) {
^
note: this fix will not be applied because it overlaps with another fix
While you're touching this, please could you do the same for |
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.
clang-tidy made some suggestions
src/sys/options.cxx
Outdated
similar_to.getMesh(), similar_to.getLocation()); | ||
} | ||
if (bout::utils::holds_alternative<Tensor<BoutReal>>(value)) { | ||
auto* localmesh = similar_to.getMesh(); |
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.
warning: auto localmesh
can be declared as auto *localmesh
[readability-qualified-auto]
auto localmesh = similar_to.getMesh();
^~~~~
auto *
src/sys/options.cxx
Outdated
} | ||
if (bout::utils::holds_alternative<Tensor<BoutReal>>(value)) { | ||
auto* localmesh = similar_to.getMesh(); | ||
if (localmesh != nullptr) { |
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.
warning: implicit conversion Mesh *
-> bool [readability-implicit-bool-conversion]
if (!localmesh) {
~^
== nullptr
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.
if (localmesh != nullptr) { | |
if (localmesh == nullptr) { |
src/sys/options.cxx
Outdated
similar_to.getMesh(), similar_to.getLocation()); | ||
} | ||
if (bout::utils::holds_alternative<Matrix<BoutReal>>(value)) { | ||
auto* localmesh = similar_to.getMesh(); |
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.
warning: auto localmesh
can be declared as auto *localmesh
[readability-qualified-auto]
auto localmesh = similar_to.getMesh();
^~~~~
auto *
src/sys/options.cxx
Outdated
} | ||
if (bout::utils::holds_alternative<Matrix<BoutReal>>(value)) { | ||
auto* localmesh = similar_to.getMesh(); | ||
if (localmesh != nullptr) { |
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.
warning: implicit conversion Mesh *
-> bool [readability-implicit-bool-conversion]
if (!localmesh) {
~^
== nullptr
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.
if (localmesh != nullptr) { | |
if (localmesh == nullptr) { |
src/sys/options.cxx
Outdated
similar_to.getMesh(), location); | ||
} | ||
if (bout::utils::holds_alternative<Matrix<BoutReal>>(value)) { | ||
auto* localmesh = similar_to.getMesh(); |
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.
warning: auto localmesh
can be declared as auto *localmesh
[readability-qualified-auto]
auto localmesh = similar_to.getMesh();
^~~~~
auto *
src/sys/options.cxx
Outdated
} | ||
if (bout::utils::holds_alternative<Matrix<BoutReal>>(value)) { | ||
auto* localmesh = similar_to.getMesh(); | ||
if (localmesh != nullptr) { |
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.
warning: implicit conversion Mesh *
-> bool [readability-implicit-bool-conversion]
if (!localmesh) {
~^
== nullptr
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 thought the huge long comment from clang-tidy
below was noise, but it actually caught the typo here!
if (localmesh != nullptr) { | |
if (localmesh == nullptr) { |
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.
Good catch, I thought the analysis was invalid as I thought the last two steps would contradict each other - but you are right 👍
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.
clang-tidy made some suggestions
clang-tidy review says "All clean, LGTM! 👍" |
Tests are failing because we also need to handle the case where the variant holds an if (bout::utils::holds_alternative<BoutReal>(value) or bout::utils::holds_alternative<int>(value)) {
BoutReal scalar_value = bout::utils::variantStaticCastOrThrow<ValueType, BoutReal>(value);
// Get metadata from similar_to, fill field with scalar_value
return filledFrom(similar_to, scalar_value);
} or alternatively: if (bout::utils::holds_alternative<BoutReal>(value)) {
BoutReal scalar_value = bout::utils::get<BoutReal>(value);
// Get metadata from similar_to, fill field with scalar_value
return filledFrom(similar_to, scalar_value);
}
if (bout::utils::holds_alternative<int>(value)) {
BoutReal scalar_value = bout::utils::get<int>(value);
// Get metadata from similar_to, fill field with scalar_value
return filledFrom(similar_to, scalar_value);
} shorter version: if (bout::utils::holds_alternative<BoutReal>(value)) {
// Get metadata from similar_to, fill field with scalar_value
return filledFrom(similar_to, bout::utils::get<BoutReal>(value));
}
if (bout::utils::holds_alternative<int>(value)) {
// Get metadata from similar_to, fill field with scalar_value
return filledFrom(similar_to, bout::utils::get<int>(value));
} |
Something seems to be making the |
Unfortunately the logs do not reveal anything. Unless you have a better idea, I would just restart to see whether it is reproducible ... |
Looking at the timings in the logs, it looks like most things just took 10 minutes longer than in the push build for some reason. Everything ran fine though. Unfortunately, it's not possible to restart just one job, it will need to restart all of the I'm going to use admin powers to merge this, the tests will get run again on the merge anyway. |
Mostly annoying with debugging, if an expected exception is thrown.