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

Merged
merged 3 commits into from
Nov 13, 2024
Merged

New "asserting" expression #814

merged 3 commits into from
Nov 13, 2024

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.

@marcoeilers
Copy link
Contributor Author

@JonasAlaif Any objections to merging this?

@JonasAlaif
Copy link
Contributor

@JonasAlaif Any objections to merging this?

Lgtm

@marcoeilers marcoeilers merged commit 08c001b into master Nov 13, 2024
5 checks passed
@marcoeilers marcoeilers deleted the meilers_asserting branch November 13, 2024 18:51
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