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

Small fixes #882

Merged
merged 16 commits into from
Apr 11, 2022
Merged

Small fixes #882

merged 16 commits into from
Apr 11, 2022

Conversation

JonasAlaif
Copy link
Contributor

Kinda fixes #878 but would prefer if @vakaras looked at it/made it less hacky

Copy link
Contributor

@vakaras vakaras left a comment

Choose a reason for hiding this comment

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

I am not sure about the removed asserts, but other changes look good to me.

@JonasAlaif
Copy link
Contributor Author

@vakaras if I convert this line:

let qvar_ty = encoder.encode_type(arg_ty).unwrap();

to:

let qvar_ty = encoder.encode_type(arg_ty).unwrap().convert_to_snapshot();

Quantification over generic types works... but I probably shouldn't use convert_to_snapshot here, but instead SnapshotEncoder::encode_type. The issue is that fn encode_quantifier() only gets a encoder: &Encoder and not SnapshotEncoder - is there any way to get the latter to this function?

@vakaras
Copy link
Contributor

vakaras commented Feb 24, 2022

@vakaras if I convert this line:

let qvar_ty = encoder.encode_type(arg_ty).unwrap();

to:

let qvar_ty = encoder.encode_type(arg_ty).unwrap().convert_to_snapshot();

Quantification over generic types works... but I probably shouldn't use convert_to_snapshot here, but instead SnapshotEncoder::encode_type. The issue is that fn encode_quantifier() only gets a encoder: &Encoder and not SnapshotEncoder - is there any way to get the latter to this function?

Isn't the snapshot encoder, a field of the encoder? Anyway, the code was written by @Aurel300, so he could probably tell more.

@Aurel300
Copy link
Member

Yeah the snapshot encoder works with the usual interface trait + state mechanism now. So, if you import crate::encoder::snapshot::SnapshotEncoderInterface, you can call the encode_snapshot_type method on Encoder. It also takes a SubstMap (which should eventually be SubstRef maybe) so generics should get properly monomorphised at the callsite.

@Aurel300 Aurel300 mentioned this pull request Mar 13, 2022
4 tasks
@JonasAlaif
Copy link
Contributor Author

Requires #895 now

@JonasAlaif JonasAlaif self-assigned this Mar 23, 2022
@JonasAlaif
Copy link
Contributor Author

Will merge this today or tomorrow if there are no objections? Though it's a small change it should actually improve generics support quite a bit

@Aurel300
Copy link
Member

@JonasAlaif Can I try to get #899 in first?

@JonasAlaif
Copy link
Contributor Author

@Aurel300 sounds good, looks like that might also fix some of the issues I might be running into with the test I just added. Let's see

@Aurel300
Copy link
Member

Status: I found some problems with generics and extern specs still. WIP but I think the test you added @JonasAlaif should be supported soon.

(Some notes:)

The wrappers (from extern spec desugaring) are not inherited the same way that is_pure is. This can result in an annoying de-sync where an implementation (e.g. of Ord) is known to be pure but cannot be encoded because it would attempt to encode a non-local DefId. Extern spec wrappers should really disappear completely, and the DefSpecificationMap should have keys of DefId instead of only LocalDefId.

The reason the wrappers exist in the first place is because PureFunctionEncoder (and by extension the backwards interpreter and MIR encoder) are mis-used to encode call infos (encode_pure_function_use) and Prusti expressions (encode_body). I extracted the latter to a separate method and made fewer things in the PureFunctionEncoder depend on an MIR body to fix the former.

@Aurel300
Copy link
Member

bors r+

@bors
Copy link
Contributor

bors bot commented Apr 11, 2022

@bors bors bot merged commit 36b94f7 into viperproject:master Apr 11, 2022
bors bot added a commit that referenced this pull request May 24, 2022
901: NFM22 examples r=JonasAlaif a=Aurel300

This is to allow linking the examples online from the paper. PRs to be done before the deadline:

- [x] #686 
- [x] #882 
- [x] #887 
- [x] #899 


Co-authored-by: Aurel Bílý <aurel.bily@gmail.com>
Co-authored-by: Jonas <jonas.fiala.cardiff@gmail.com>
bors bot added a commit that referenced this pull request May 27, 2022
901: NFM22 examples r=Aurel300 a=Aurel300

This is to allow linking the examples online from the paper. PRs to be done before the deadline:

- [x] #686 
- [x] #882 
- [x] #887 
- [x] #899 


972: Fix slice with range encoding r=JonasAlaif a=JonasAlaif

Fixes #960
Issue is described there. Not sure if this is the correct way to do the error reporting?
It would be really nice to just have a contract for `index` and `index_mut` and report the error as a precondition violation of those. E.g. I really don't want to hardcode the pledge required for `index_mut` by hand.

Co-authored-by: Aurel Bílý <aurel.bily@gmail.com>
Co-authored-by: Jonas <jonas.fiala.cardiff@gmail.com>
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.

Incorrect encoding of enum discriminant type
3 participants