Skip to content

New "asserting" expression#814

Merged
marcoeilers merged 3 commits into
masterfrom
meilers_asserting
Nov 13, 2024
Merged

New "asserting" expression#814
marcoeilers merged 3 commits into
masterfrom
meilers_asserting

Conversation

@marcoeilers

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

@JonasAlaif Any objections to merging this?

@JonasAlaif

Copy link
Copy Markdown
Contributor

@JonasAlaif Any objections to merging this?

Lgtm

@marcoeilers marcoeilers merged commit 08c001b into master Nov 13, 2024
@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