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

New "asserting" expression #814

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

New "asserting" expression #814

wants to merge 2 commits into from

Conversation

marcoeilers
Copy link
Contributor

Adds a new expression asserting (a) in e where a is some assertion and e some expression.
Evaluating that expression first checks if a holds, and if it does, evaluates to the value of e.

I took the syntax and some tests from @dewert99's earlier PR #663 (thank you!!) but redid the rest because the parser and PAST have changed a lot since that PR was made.

Requires changes in Silicon and Carbon to support the new expression.

@JonasAlaif
Copy link
Contributor

I was thinking it would also be nice to introduce a e1; e2 syntax for expressions which would desugar to let __tmp = e1 in e2. That's a bit tangential to this, but one could then also write check(a); e2 with a function check(b: Bool): ? requires b.

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