program main
  struct PrimitiveRecord
    field id: i32
    field active: bool
    field label: string
  fn make_record(id: i32, label: string) -> PrimitiveRecord
    construct PrimitiveRecord
      field id
        var id
      field active
        binary =
          var id
          int 7
      field label
        var label
  fn expected_record() -> PrimitiveRecord
    call make_record
      int 7
      string "alpha"
  fn inactive_record() -> PrimitiveRecord
    construct PrimitiveRecord
      field id
        int 3
      field active
        bool false
      field label
        string "beta"
  fn echo_record(record: PrimitiveRecord) -> PrimitiveRecord
    var record
  fn local_record(label: string) -> PrimitiveRecord
    local let record: PrimitiveRecord
      call make_record
        int 7
        var label
    call echo_record
      var record
  fn record_id(record: PrimitiveRecord) -> i32
    field-access id
      var record
  fn record_active(record: PrimitiveRecord) -> bool
    field-access active
      var record
  fn record_label(record: PrimitiveRecord) -> string
    field-access label
      var record
  fn label_matches(record: PrimitiveRecord, label: string) -> bool
    binary =
      field-access label
        var record
      var label
  fn active_score(record: PrimitiveRecord) -> i32
    if
      field-access active
        var record
      field-access id
        var record
      int 0
  fn label_len(record: PrimitiveRecord) -> i32
    call std.string.len
      field-access label
        var record
  fn main() -> i32
    call active_score
      call local_record
        string "alpha"
  test "primitive struct i32 field access"
    binary =
      call record_id
        call expected_record
      int 7
  test "primitive struct bool field predicate"
    call record_active
      call expected_record
  test "primitive struct bool field false branch"
    binary =
      call active_score
        call inactive_record
      int 0
  test "primitive struct string field equality"
    call label_matches
      call expected_record
      string "alpha"
  test "primitive struct string field length"
    binary =
      call label_len
        call expected_record
      int 5
  test "primitive struct local param return call flow"
    binary =
      call active_score
        call local_record
          string "alpha"
      int 7
  test "primitive struct string field access return"
    binary =
      call record_label
        call local_record
          string "alpha"
      string "alpha"
