Skip to content

Improve ergonomics of failing instruction assert and assert_vectorΒ #324

@jan-ferdinand

Description

@jan-ferdinand

When Triton VM tries to execute instruction assert while the top of its stack is unequal to 1, it fails. Currently, the error it returns does not give any further context. It would be beneficial for developers writing Triton assembly if instruction assert could be decorated with some context, indicating which of potentially many assert statements failed, and potentially also why it failed.

One idea would be to allow specifying an error code:

push 42
assert 127 ; Triton VM returns `InstructionError::AssertionFailed(127)`

Another possibility is to be more explicit about the failure reason:

push 42
assert [expect = "The moon should be blue."]

User-provided context should be optional. That is, the following program should remain syntactically correct (even though it will not halt successfully):

push 42
assert
halt

Note that all syntax examples are simply first drafts of suggestions and should be designed properly.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions