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

incorrect spec for String::len? #1164

Open
arnaudgolfouse opened this issue Oct 17, 2024 · 4 comments
Open

incorrect spec for String::len? #1164

arnaudgolfouse opened this issue Oct 17, 2024 · 4 comments

Comments

@arnaudgolfouse
Copy link
Collaborator

arnaudgolfouse commented Oct 17, 2024

impl ShallowModel for String {
    type ShallowModelTy = Seq<char>;
}

#[ensures(result@ == self@.len())]
fn len(&self) -> usize;

The length of the string is in bytes, so this spec is not correct I think? Same for str::split_at. Although I guess there is no way no observe this at the moment...

@xldenis
Copy link
Collaborator

xldenis commented Oct 17, 2024

Hmm yea I guess we should relax that to >=?

@arnaudgolfouse
Copy link
Collaborator Author

This would work, but shouldn't we actually give the correct length? With a logical function utf8_len(char) -> usize
I guess this would make str::len hard on provers, but if we use >= it would be a bit useless.

@xldenis
Copy link
Collaborator

xldenis commented Oct 18, 2024

Depends on what we need it for really.

@jhjourdan
Copy link
Collaborator

Do we want to formalized Unicode? No.
So the only alternative we have is not supporting len at all, which is definitely an option.

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

No branches or pull requests

3 participants