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 constants #73

Open
yannbolliger opened this issue Feb 12, 2021 · 2 comments
Open

Support constants #73

yannbolliger opened this issue Feb 12, 2021 · 2 comments
Labels
extraction Feature or bug with the extraction phase feature Something needs to be added

Comments

@yannbolliger
Copy link
Collaborator

For example something like this:

const DEFAULT_PORT: u64 = 1000;

Currently, this fails with: error: Unsupported tree: Other kind of item

@romac romac added extraction Feature or bug with the extraction phase feature Something needs to be added labels Feb 26, 2021
@yannbolliger
Copy link
Collaborator Author

Currently, we serialise a triple of (FunDef, ClassDef, ADTSort) to give to the Stainless backend. This leaves no room for top-level constants. A solution could be to scope the constants inside of some ADT.

@romac
Copy link
Member

romac commented Mar 10, 2021

Can we just extract them as FunDefs and rewrite mentions to constants to function calls?

ie.

const DEFAULT_PORT: u64 = 1000;

fn test() {
  let x = DEFAULT_PORT;
}

would be extracted as

def DEFAULT_PORT(): U64 = 1000;

def test(): Unit = {
  val x = DEFAULT_PORT();
}

We may also want to add a @inline annotation to the extracted FunDef to eventually erase them in the Stainless pipeline.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extraction Feature or bug with the extraction phase feature Something needs to be added
Projects
None yet
Development

No branches or pull requests

2 participants