Skip to content

Support for trapping #41

Closed
Closed

Description

@sunfishcode

AstSemantics.md has the concept of a trap, which means

execution [...] is terminated and abnormal termination is reported to the outside environment.

Several operators are defined to trap, such as integer division when the denominator is zero. What's the best way to represent this in OCaml? Would an exception be appropriate?

In the future, trapping behavior may be made customizable, though I don't think it's necessary to try to anticipate this in the current code.

Activity

  1. rossberg commented on Sep 2, 2015

    @rossberg
    Member

    An exception seems perfectly adequate. We can either just use the existing Error.error for that, or, if we care about distinguishing expected from unexpected runtime errors, introduce a new Eval.Trap exception.

  2. lukewagner commented on Sep 2, 2015

    @lukewagner
    Member

    It'd also be nice to add a new (asserttrap (invoke ...)) command to test trapping behavior.

  3. lukewagner commented on Sep 17, 2015

    @lukewagner
    Member

    Given use of ML exceptions and ability to test with assert_trap (#74, #76), I think this issue is resolved, but feel free to reopen if there is more to do here. When we specify JS<->wasm integration, we'll have to talk about how spec traps turn into JS exceptions (I assume), but I think that's outside ml-proto (it's just what the host does when Eval.invoke throws).

  4. added a commit that references this issue on Mar 2, 2023
  5. added a commit that references this issue on Jul 12, 2023
  6. added a commit that references this issue on Sep 4, 2024
  7. added a commit that references this issue on Nov 6, 2024
  8. added a commit that references this issue on Sep 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions