Skip to content

Conversation

@brandonpollack23
Copy link
Collaborator

@brandonpollack23 brandonpollack23 commented Jan 9, 2026

In the same vein as #57 , preconditions also must be wrapped in a closure to correctly handle any included return statements and prevent them from returning from the instrumented function.

This PR also modifies the tests for execution order to include the return keyword, removes the hacky Parse implementations used in those tests, and instead constructs the appropriate *Condition structs directly.

Fixes #66

Copy link
Collaborator Author

brandonpollack23 commented Jan 9, 2026

@brandonpollack23 brandonpollack23 marked this pull request as ready for review January 9, 2026 05:14
@brandonpollack23 brandonpollack23 force-pushed the vscode_rustanalyzer_config branch from 4480c59 to a4cf0b8 Compare January 9, 2026 05:20
@brandonpollack23 brandonpollack23 force-pushed the closure_for_preconditions branch from 820fa74 to 15af57f Compare January 9, 2026 05:20
@brandonpollack23 brandonpollack23 marked this pull request as draft January 9, 2026 05:22
@mkovaxx mkovaxx changed the base branch from vscode_rustanalyzer_config to graphite-base/69 January 9, 2026 07:10
@mkovaxx mkovaxx force-pushed the closure_for_preconditions branch from 15af57f to dd590ad Compare January 9, 2026 07:11
@mkovaxx mkovaxx changed the base branch from graphite-base/69 to main January 9, 2026 07:11
@mkovaxx mkovaxx force-pushed the closure_for_preconditions branch from dd590ad to 97a6037 Compare January 9, 2026 07:11
@brandonpollack23 brandonpollack23 force-pushed the closure_for_preconditions branch from 97a6037 to 3a9b605 Compare January 20, 2026 08:36
Copy link
Owner

@mkovaxx mkovaxx left a comment

Choose a reason for hiding this comment

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

This is looking good, thanks!

Please add/extend an integration test in anodized to demonstrate that return statements in conditions are now handled correctly.

The easiest way is likely to change the following test case to be "maximally evil":

#[spec(
requires: [
log.push("requires1") == (),
log.push("requires2") == (),
],
maintains: [
log.push("maintains1") == (),
log.push("maintains2") == (),
],
captures: [
log.push("captures1") as _alias1,
log.push("captures2") as _alias2,
],
ensures: [
log.push("ensures1") == (),
log.push("ensures2") == (),
],
)]
fn func(log: &mut Vec<&'static str>) {
log.push("body");
return;
}

Copy link
Collaborator Author

This change should do it

@brandonpollack23 brandonpollack23 force-pushed the closure_for_preconditions branch 2 times, most recently from 9a2c5e4 to 2552d58 Compare January 20, 2026 11:26
Copy link
Collaborator Author

This is looking good, thanks!

Please add/extend an integration test in anodized to demonstrate that return statements in conditions are now handled correctly.

The easiest way is likely to change the following test case to be "maximally evil":

#[spec(
requires: [
log.push("requires1") == (),
log.push("requires2") == (),
],
maintains: [
log.push("maintains1") == (),
log.push("maintains2") == (),
],
captures: [
log.push("captures1") as _alias1,
log.push("captures2") as _alias2,
],
ensures: [
log.push("ensures1") == (),
log.push("ensures2") == (),
],
)]
fn func(log: &mut Vec<&'static str>) {
log.push("body");
return;
}

Ok latest push has all the comments addressed, have at it ☺️

Copy link
Owner

@mkovaxx mkovaxx left a comment

Choose a reason for hiding this comment

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

Good stuff! This is likely the last round before we can land it. :)

@brandonpollack23 brandonpollack23 force-pushed the closure_for_preconditions branch from 2552d58 to dd4c087 Compare January 20, 2026 12:54
Copy link
Collaborator Author

done 😏

Copy link
Owner

@mkovaxx mkovaxx left a comment

Choose a reason for hiding this comment

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

Getting super close. Just a few doc and test things.

Copy link
Owner

@mkovaxx mkovaxx left a comment

Choose a reason for hiding this comment

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

Please also update the README in anodized-core.

@brandonpollack23 brandonpollack23 force-pushed the closure_for_preconditions branch 3 times, most recently from 2368a2c to 143326c Compare January 20, 2026 14:09
Copy link
Owner

@mkovaxx mkovaxx left a comment

Choose a reason for hiding this comment

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

Last one!

@mkovaxx mkovaxx changed the title Wrap all preconditions in a closure to prevent early return. fix: Wrap preconditions in a closure to prevent early return Jan 21, 2026
@brandonpollack23 brandonpollack23 force-pushed the closure_for_preconditions branch 2 times, most recently from 8baee45 to 7093e7b Compare January 21, 2026 02:00
@brandonpollack23 brandonpollack23 marked this pull request as ready for review January 21, 2026 02:01
@brandonpollack23 brandonpollack23 force-pushed the closure_for_preconditions branch from 7093e7b to f5fc4f0 Compare January 21, 2026 02:08
Copy link
Collaborator Author

Ok I think we sorted it out

Copy link
Owner

@mkovaxx mkovaxx left a comment

Choose a reason for hiding this comment

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

@brandonpollack23 Looks good, thanks!

Please add some detail to the PR description, check that cargo test passes locally, then squash and merge.

Copy link
Collaborator Author

brandonpollack23 commented Jan 21, 2026

Merge activity

  • Jan 21, 5:05 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jan 21, 5:27 AM UTC: Graphite couldn't merge this PR because it failed for an unknown reason (GitHub is reporting that this PR is not mergeable, despite passing required status checks defined by your branch protection rules. Please check your rulesets for additional blocking criteria. Graphite Merge Queue does not currently support rulesets. Please contact Graphite support for further assistance.).

@brandonpollack23 brandonpollack23 merged commit 8a9f84f into main Jan 21, 2026
4 checks passed
@brandonpollack23 brandonpollack23 deleted the closure_for_preconditions branch January 21, 2026 07:18
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.

bug: naked expressions need to be guarded for returns

3 participants