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

Add a contract node to the AST #1955

Merged
merged 2 commits into from
Jun 13, 2024
Merged

Add a contract node to the AST #1955

merged 2 commits into from
Jun 13, 2024

Conversation

yannham
Copy link
Member

@yannham yannham commented Jun 12, 2024

Follow-up of #1954. Related to #1466 and #1460.

This PR continues further the work of properly separating custom contracts in the AST in order to maintain more run-time information and be able, in the long run, to perform operations like boolean or on a larger class of contracts and to provide better error messages when contracts (in particular parametric contracts) are misused.

Note that this is a backward-incompatible change on paper, because before one could apply a custom contract built from a predicate as a function (taking a label and a value, and returning a new value). However, in practice, it's neither officially supported nor recommended - users are requested to use std.contract.apply to manipulate contracts - and thus we don't expect much actual breakage to happen. If there is breakage, we can always special case the evaluation of CustomContract::Predicate to act as a function in the evaluator.

@github-actions github-actions bot temporarily deployed to pull request June 12, 2024 17:39 Inactive
@github-actions github-actions bot temporarily deployed to pull request June 13, 2024 09:54 Inactive
@github-actions github-actions bot temporarily deployed to pull request June 13, 2024 13:53 Inactive
This commit continues the work of properly separating custom contracts
in the AST, in order to maintain more run-time information and be able,
in the long run, to perform operations like boolean `or` on a larger
class of contracts and to provide better error messages in some
situations.

This commit focuses on predicates, built using the
`std.contract.from_predicate` which now acts as some kind of type
constructor. `%contract/apply%` then performs the conversion of this
predicate to a generic custom contract (a partial identity function).

Note that this is a backward-incompatible change on paper, because
before one could apply a custom contract built from a predicate as a
function (taking a label and a value, and returning a new value).
However, in practice, it's not officially supported - users are
requested to use `std.contract.apply` to manipulate contracts - and thus
we don't expect actual breakage to happen.
@github-actions github-actions bot temporarily deployed to pull request June 13, 2024 14:04 Inactive
@yannham yannham marked this pull request as ready for review June 13, 2024 14:05
@yannham yannham requested review from jneem and vkleen June 13, 2024 14:05
core/src/pretty.rs Show resolved Hide resolved
core/src/term/mod.rs Outdated Show resolved Hide resolved
core/src/term/mod.rs Show resolved Hide resolved
core/src/term/mod.rs Show resolved Hide resolved
Co-authored-by: jneem <joeneeman@gmail.com>
@github-actions github-actions bot temporarily deployed to pull request June 13, 2024 15:01 Inactive
@yannham yannham added this pull request to the merge queue Jun 13, 2024
Merged via the queue into master with commit d8cdd77 Jun 13, 2024
5 checks passed
@yannham yannham deleted the task/contract-ast-node branch June 13, 2024 15:56
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.

2 participants