Skip to content
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

Int ghost methods #1281

Merged
merged 8 commits into from
Dec 3, 2024
Merged

Conversation

arnaudgolfouse
Copy link
Collaborator

@arnaudgolfouse arnaudgolfouse commented Dec 3, 2024

Allow using operators (+, *...) on Int in ghost code.

This works because it is never possible to get an Int in normal (non-ghost) code.

Fixes #1271.

@arnaudgolfouse
Copy link
Collaborator Author

arnaudgolfouse commented Dec 3, 2024

Right now this bumps into limitations of the purity check, so

#[pure]
fn add(x: Int, y: Int) -> Int {
    x + y
}

is rejected because the trait function Add::add is not #[pure] (although <Int as Add>::add is)

@jhjourdan
Copy link
Collaborator

is rejected because the trait function Add::add is not #[pure] (although ::add is)

Huh, you mean that we don't resolve trait methods in the purity check? We should!

@arnaudgolfouse
Copy link
Collaborator Author

Hum nevermind, I just forgot a #[pure] annotations 😅

@arnaudgolfouse arnaudgolfouse force-pushed the int-ghost-methods branch 3 times, most recently from 05351d4 to d285d5a Compare December 3, 2024 15:05
"mul" | "add" | "sub" | "div" | "rem" | "neg" | "box_new" | "deref_method"
| "deref_mut_method" => true,
"box_new" | "deref_method" | "deref_mut_method" => true,
Copy link
Collaborator

Choose a reason for hiding this comment

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

🎉

@jhjourdan
Copy link
Collaborator

Overall, LGTM.

@laurentder : this should fix your issues about machine arithmetics in pearlite specifications, since they are all rewritten.

@arnaudgolfouse arnaudgolfouse merged commit 7f18d4f into creusot-rs:master Dec 3, 2024
6 checks passed
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.

Operations on Int in ghost code
2 participants