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 literals in ghost code #1251

Open
arnaudgolfouse opened this issue Nov 25, 2024 · 5 comments
Open

Int literals in ghost code #1251

arnaudgolfouse opened this issue Nov 25, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@arnaudgolfouse
Copy link
Collaborator

There should be an easy way to create an Int in ghost code. Currently you can do

ghost! {
    let x: Int = *Int::new(42);
};

But this is very inelegant.

@arnaudgolfouse arnaudgolfouse added the enhancement New feature or request label Nov 25, 2024
@arnaudgolfouse
Copy link
Collaborator Author

arnaudgolfouse commented Nov 25, 2024

One easy way would be to have int prefix, and in the ghost! macro desugars 42int into *Int::new(42). Its a bit weird since this suffix does not exists in pearlite though.

@jhjourdan
Copy link
Collaborator

That's only a solution to half the problem, since this will not work in ghost functions that do not use the ghost! macro.

What about *42.into(), by defining e.g., Ghost<Int> : From<u32>?

@arnaudgolfouse
Copy link
Collaborator Author

Unfortunately this struggles with type inference, even

ghost! {
    let x: Int = *0u32.into();
};

does not work 😕 (type annotations needed on the into call)

@jhjourdan
Copy link
Collaborator

@xldenis where is the Rust RFC with support for custom integer types?

@xldenis
Copy link
Collaborator

xldenis commented Nov 25, 2024

It never even made it to the stage of an rfc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants