Skip to content

Fix empty assertions with "assertion" description - #1053

Merged
jaisnan merged 10 commits into
model-checking:mainfrom
jaisnan:fix-assertion-empty-checks
Apr 15, 2022
Merged

jaisnan merged 10 commits into
model-checking:mainfrom
jaisnan:fix-assertion-empty-checks

Conversation

@jaisnan

@jaisnan jaisnan commented Apr 15, 2022 •

Copy link
Copy Markdown
Contributor

Description of changes:

  1. Fixes empty assertions by adding property classes to assert_false. This fix should affect a lot of test cases wherever assert_false was used.

  2. Adds new property class variants - cover, abort, unequal-assign.

  3. Refactor creating location with property types from codegen to Stmt::assert.

  4. Add basic assert to Stmt::assert to make sure Property_Class and Description are 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

  • Each commit message has a non-empty body, explaining why the change was made
  • Methods or procedures are documented
  • Regression or unit tests are included, or existing tests cover the modified code
  • My PR is restricted to a single feature or bugfix

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.

@jaisnan
jaisnan requested a review from a team as a code owner April 15, 2022 06:19

@tedinski tedinski left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this

Location::create_location_with_property(message, property_name, loc);

Stmt::assert(cond, property_name, message, property_location)
Stmt::assert(cond, property_name, message, loc)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jaisnan jaisnan Apr 15, 2022 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jaisnan

jaisnan commented Apr 15, 2022

Copy link
Copy Markdown
Contributor Author

@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.

@tedinski

Copy link
Copy Markdown
Contributor

do you think we need tests (ui tests) specifically for this bug

I think your change to the function signature and addition of asserts should cover things nicely.

@jaisnan
jaisnan requested a review from tedinski April 15, 2022 19:56
@tedinski tedinski mentioned this pull request Apr 15, 2022
@jaisnan
jaisnan merged commit 96fba80 into model-checking:main Apr 15, 2022
tedinski pushed a commit to tedinski/rmc that referenced this pull request Apr 26, 2022
* Fix empty assertions with "assertion" description
tedinski pushed a commit that referenced this pull request Apr 27, 2022
* Fix empty assertions with "assertion" description
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing Property String and Description in some Checks

2 participants