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

Syntax for Return Types #463

Closed
DavePearce opened this issue Feb 4, 2015 · 2 comments
Closed

Syntax for Return Types #463

DavePearce opened this issue Feb 4, 2015 · 2 comments

Comments

@DavePearce
Copy link
Member

Currently, there is a distinction between the syntax for parameter and return types which is inconsistent. Specifically, function parameters are represented as instances WhileyFile.Parameter, whilst function returns are represented as a single instance of TypePattern.

This inconsistency does cause some surprising issues:

  • During verification condition generation, we have to carefully switch between the environment for a body and that of the postcondition.
  • A single instance of RegisterDeclarations is not sufficient for all declared variables in a function, as it cannot include the return value.
  • On the other hand, there are some neat things you can do with the type pattern in terms of post-conditions.

Two examples related to the latter:

function f() -> { int x, int y }
ensures x > y:
    ...

(this is fine)

function f({int x, int y}) -> int
requires x > y:
    ...

(this is not fine).

Furthermore, I think it would be nice to be able to write this:

function f{int x, int y} -> int
requires x > y:
    ...

Which describes a function with named parameter values.

@DavePearce
Copy link
Member Author

There is some connection with #480 here.

@DavePearce
Copy link
Member Author

Resolved as part of #537

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant