Skip to content

Add assertions - #1389

Merged
eponier merged 2 commits into
mainfrom
cassert
Feb 23, 2026
Merged

Add assertions#1389
eponier merged 2 commits into
mainfrom
cassert

Conversation

@vbgl

@vbgl vbgl commented Feb 20, 2026

Copy link
Copy Markdown
Member

Description

The changes in this PR have been extracted from #1170.

Assertions can be written in Jasmin programs as

assert("label", b);

where "label" is an informative string literal and b a boolean
expression.

At run-time, they evaluate their argument b and fail if it is not
true; do nothing otherwise.

Those assertions are mostly meant to be used internally. A very early
compilation pass removes these assertions.

Checklist

  • Add a changelog entry in changes if the PR is a user-visible change
  • Add one or several tests to compiler/tests if it makes sense, especially if it is a bug fix
  • Update the documentation if needed

Extraction to EasyCrypt (TODO in toEC.ml) is intentionally left as future work.

Should this be more documented?

@vbgl

vbgl commented Feb 20, 2026

Copy link
Copy Markdown
Member Author

I’ve just added minimal documentation & rephrased the commit message.

eponier
eponier previously approved these changes Feb 20, 2026

@eponier eponier left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't spot anything fishy, except the extraction to EasyCrypt and the safety checker which are both future work I believe.

I have just some minor comments on remove_assert.v.

Comment thread proofs/compiler/remove_assert.v Outdated
Comment thread proofs/compiler/remove_assert.v Outdated
@vbgl
vbgl force-pushed the cassert branch 2 times, most recently from 23fe4fd to e5b0be8 Compare February 21, 2026 04:48
Assertions can be written in Jasmin programs as

    assert("label", b);

where `"label"` is an informative string literal and `b` a boolean
expression.

In the source semantics, they evaluate their argument `b` and fail if it
is not true; do nothing otherwise.

Those assertions are mostly meant to be used internally. A very early
compilation pass removes these assertions.

Co-authored-by: Vincent Laporte <Vincent.Laporte@inria.fr>

@eponier eponier left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is now even some support in the safety checker.

@eponier
eponier merged commit fbe7edd into main Feb 23, 2026
1 check passed
@eponier
eponier deleted the cassert branch February 23, 2026 09:29
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.

3 participants