Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Add preconditions and postconditions #417

Open
jyn514 opened this issue May 9, 2020 · 5 comments
Open

Add preconditions and postconditions #417

jyn514 opened this issue May 9, 2020 · 5 comments
Labels
enhancement New feature or request good first issue Good for newcomers testing More tests for the compiler!

Comments

@jyn514
Copy link
Owner

jyn514 commented May 9, 2020

https://docs.rs/contracts/0.4.0/contracts/

  • self-documenting
  • catches more bugs
  • only runs in debug mode
  • what's not to love?
@jyn514 jyn514 added enhancement New feature or request testing More tests for the compiler! labels May 9, 2020
@jyn514
Copy link
Owner Author

jyn514 commented May 9, 2020

To avoid compiling this for end users, a friend suggested using a feature which is enabled by default only in dev mode:

[profile.dev]
features = ["contracts", "color-backtrace"]

@karroffel
Copy link

Just mentioning that contracts by default will always run, but you can use the override_debug feature to make them debug only. In that case no further profile configuration should be needed, at least for the contracts crate.

@jyn514
Copy link
Owner Author

jyn514 commented May 11, 2020

Just mentioning that contracts by default will always run, but you can use the override_debug feature to make them debug only. In that case no further profile configuration should be needed, at least for the contracts crate.

This will not run the contracts, but it will still compile the contracts crate.

@karroffel
Copy link

But compiling the attributes without the contracts crate will fail, unless I misunderstand how you intend to use the crate 🙃

@jyn514
Copy link
Owner Author

jyn514 commented May 11, 2020

Something like this:

#[cfg_attr(feature = "contracts", post(old(self.lval) || old(self) == ret))]
fn rval(self) -> Expr {
    unimplemented!();
}

That does seem super verbose though ...

@jyn514 jyn514 added the good first issue Good for newcomers label Aug 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request good first issue Good for newcomers testing More tests for the compiler!
Projects
None yet
Development

No branches or pull requests

2 participants