program main
  enum Status
    variant Ready
    variant Blocked
  enum Reading
    variant Missing
    variant Value i32
  struct TaggedReading
    field status: Status
    field reading: Reading
  fn make_tagged(status: Status, reading: Reading) -> TaggedReading
    construct TaggedReading
      field status
        var status
      field reading
        var reading
  fn ready_value(payload: i32) -> TaggedReading
    call make_tagged
      enum-variant Status.Ready
      enum-variant Reading.Value
        var payload
  fn missing_blocked() -> TaggedReading
    call make_tagged
      enum-variant Status.Blocked
      enum-variant Reading.Missing
  fn echo_tagged(tagged: TaggedReading) -> TaggedReading
    var tagged
  fn local_tagged(payload: i32) -> TaggedReading
    local let tagged: TaggedReading
      call ready_value
        var payload
    call echo_tagged
      var tagged
  fn status_of(tagged: TaggedReading) -> Status
    field-access status
      var tagged
  fn reading_of(tagged: TaggedReading) -> Reading
    field-access reading
      var tagged
  fn is_ready(tagged: TaggedReading) -> bool
    binary =
      field-access status
        var tagged
      enum-variant Status.Ready
  fn reading_matches(tagged: TaggedReading, reading: Reading) -> bool
    binary =
      field-access reading
        var tagged
      var reading
  fn reading_code(tagged: TaggedReading) -> i32
    match
      subject
        field-access reading
          var tagged
      arm Reading.Missing
        int 0
      arm Reading.Value payload
        var payload
  fn main() -> i32
    call reading_code
      call local_tagged
        int 42
  test "enum struct field payloadless equality"
    binary =
      call status_of
        call missing_blocked
      enum-variant Status.Blocked
  test "enum struct field unary payload equality"
    call reading_matches
      call ready_value
        int 7
      enum-variant Reading.Value
        int 7
  test "enum struct field access return"
    binary =
      call reading_of
        call missing_blocked
      enum-variant Reading.Missing
  test "enum struct field local param return call flow"
    binary =
      call reading_code
        call local_tagged
          int 9
      int 9
  test "enum struct field match missing"
    binary =
      call reading_code
        call missing_blocked
      int 0
  test "enum struct field status predicate"
    call is_ready
      call ready_value
        int 11
