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

Support private functions and old expressions in Motoko-to-Viper translation #3675

Merged
merged 9 commits into from
Jan 5, 2023

Conversation

aterga
Copy link
Contributor

@aterga aterga commented Jan 3, 2023

This PR adds support for translating private Motoko functions into Viper. The translation is mostly analogous to that for public async functions. However, a private function does not have to be called from a state that satisfies the canister invariant (i.e., it may be called even in intermediate states), and a private function does not have to preserve the canister invariant (i.e., it may result in an intermediate state).

Additionally, we add old expressions to enable useful specs in private actor functions, e.g.:

private func reward() : () {
  count += 1;
  assert:return count == old count + 1;
};

@aterga aterga requested a review from crusso January 3, 2023 20:53
@crusso crusso requested a review from ggreif January 3, 2023 23:26
@crusso
Copy link
Contributor

crusso commented Jan 3, 2023

(I'm off tomorrow, @ggreif can you take a look if on duty?)

@github-actions
Copy link

github-actions bot commented Jan 3, 2023

Comparing from aa17d7e to c0fd8bb:
The produced WebAssembly code seems to be completely unchanged.

…finity/motoko into arshavir--viper--support-private-funcs
@aterga aterga changed the title Support private functions in Motoko-to-Viper translation Support private functions and old expressions in Motoko-to-Viper translation Jan 4, 2023
@aterga aterga added the viper Verification related label Jan 4, 2023
src/mo_frontend/parser.mly Outdated Show resolved Hide resolved
Copy link
Contributor

@ggreif ggreif left a comment

Choose a reason for hiding this comment

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

LGTM! A few nits noted. Also test/viper/ok/private.silicon.ok is an empty file, make -C test/viper accept should get rid of it.

Maybe also update the src/viper/README.md regarding the new features?

@ggreif ggreif changed the title Support private functions and old expressions in Motoko-to-Viper translation Support private functions and old expressions in Motoko-to-Viper translation Jan 4, 2023
ggreif referenced this pull request in dfinity/vscode-motoko Jan 4, 2023
src/lowering/desugar.ml Outdated Show resolved Hide resolved
src/mo_def/arrange.ml Outdated Show resolved Hide resolved
@ggreif
Copy link
Contributor

ggreif commented Jan 4, 2023

As you see I am not a fan of redundant parentheses :->
feel free to ignore those nits.

@aterga aterga requested a review from ggreif January 4, 2023 17:36
Copy link
Contributor

@ggreif ggreif left a comment

Choose a reason for hiding this comment

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

Feel free to set the automerge-squash label

@aterga aterga added the automerge-squash When ready, merge (using squash) label Jan 5, 2023
@mergify mergify bot merged commit 44ecd26 into master Jan 5, 2023
@mergify mergify bot deleted the arshavir--viper--support-private-funcs branch January 5, 2023 10:21
@mergify mergify bot removed the automerge-squash When ready, merge (using squash) label Jan 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
viper Verification related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants