Repository navigation
Fix empty assertions with "assertion" description - #1053
Conversation
tedinski
left a comment
There was a problem hiding this comment.
Nice work finding these bugs
| let msg = message.into(); | ||
|
|
||
| stmt!(Assert { cond, property_class, msg }, loc) | ||
| stmt!(Assert { cond, property_class, msg }, loc_with_property) |
There was a problem hiding this comment.
is this the root cause of the bug? seems like this went from accidentally ignoring them to using them?
|
|
||
| pub fn assert_false(msg: &str, loc: Location) -> Self { | ||
| Stmt::assert(Expr::bool_false(), "assert_false", msg, loc) | ||
| pub fn assert_false(property_name: &str, message: &str, loc: Location) -> Self { |
| Location::create_location_with_property(message, property_name, loc); | ||
|
|
||
| Stmt::assert(cond, property_name, message, property_location) | ||
| Stmt::assert(cond, property_name, message, loc) |
There was a problem hiding this comment.
Ah, maybe this answers my previous question about root cause. So we went from applying it early, to applying it in a later choke point (with asserts looking for reasonable values), to ensure we don't forget to do so. Right? Seems like an excellent change. Nice.
There was a problem hiding this comment.
Yeah, that's about it. It wasn't consistently applied everywhere which created the issue for a few assert_false calls. Now, Stmt::assert all ensure structure and quality of the arguments that it needs.
|
@tedinski do you think we need tests (ui tests) specifically for this bug? as far i can see, the bug is fixed within all the regression tests wherever it was happening but there's no test for the bug itself. |
I think your change to the function signature and addition of asserts should cover things nicely. |
* Fix empty assertions with "assertion" description
* Fix empty assertions with "assertion" description
Description of changes:
Fixes empty assertions by adding property classes to
assert_false. This fix should affect a lot of test cases whereverassert_falsewas used.Adds new property class variants -
cover,abort,unequal-assign.Refactor creating location with property types from
codegentoStmt::assert.Add basic assert to
Stmt::assertto make sureProperty_ClassandDescriptionare not empty.Resolved issues:
Resolves #1051
Call-outs:
This doesn't yet add any unit tests to the Python parser or UI tests. That can be addressed in a future PR.
Testing:
How is this change tested? Codegen assertion.
Is this a refactor change? Yes.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.