title: kaitai instance value ternary: can't combine output types
body: <p>I've created a Kaitai Struct <code>.ksy</code> for two very similar Digilent log file formats. The second format (<code>openlogger</code>) is an extension of the first (<a href="https://github.com/Digilent/dlog-utils" rel="nofollow noreferrer"><code>openscope</code></a>) with two additional fields in the struct. The scope is basically a single-channel logger; the additional logger fields describe the number of active channels (a <code>u1</code>, max 8) and the channel to sample order map (a <code>u1 x 8</code>).</p>
  
  <p>I'm attempting to harmonise the interface for the two formats by synthesising always-present fields for the <code>num_channels</code> and <code>channel_map</code>; this has worked fine for the <code>num_channels</code> instance. However I can't figure out how to create a suitable value for the channel map, the <code>.ksy</code> below reports an error:
  <code>/types/body/types/header/instances/channel_order/value: can't combine output types: ArrayType(Int1Type(false)) vs CalcBytesType</code></p>
  
  <p>I can't figure out how I can represent the <code>if_false</code> part (<code>[0]</code>) as an ArrayType.</p>
  
  <p>Is there a better way to approach this?</p>
  
  <pre><code>meta:
    id: dlog
    file-extension: dlog
  seq:
    - id: endianness
      type: u1
      doc: 0 - little endian 1 - big endian
    - id: body
      type: body
  types:
    body:
      meta:
        endian:
          switch-on: _root.endianness
          cases:
            0: le
            1: be
      seq:
        - id: header
          type: header
      instances:
        data:
          pos: header.start_of_data
          type: data
      types:
        header:
          seq:
          - id: sample_size
            type: u1
          - id: header_size
            type: u2
          - id: start_of_data
            type: u2
          - id: dlog_format
            type: u2
            enum: dlog_formats
          - id: dlog_version
            type: u4
  
          - id: voltage_units
            type: u8
          - id: stop_reason
            type: u4
            enum: stop_reasons
            #...
  
          - id: num_openlogger_channels
            type: u4
            if: dlog_format == dlog_formats::openlogger
            doc: number of channels per sample
          - id: openlogger_channel_map
            type: u1
            repeat: expr
            repeat-expr: 8
            if: dlog_format == dlog_formats::openlogger
            doc: channel order
  
          instances:
            num_channels:
              value: 'dlog_format == dlog_formats::openlogger ? num_openlogger_channels : 1'
            channel_map:
              value: 'dlog_format == dlog_formats::openlogger ? openlogger_channel_map : [0]'
  
        data:
          seq:
          - id: samples
            type: sample
            repeat: eos
          types:
            sample:
              seq:
                - id: channel
                  type:
                    switch-on: _root.body.header.sample_size
                    cases:
                      1: s1
                      2: s2
                      4: s4
                  repeat: expr
                  repeat-expr: _root.body.header.num_channels
  
  enums:
    dlog_formats:
      1: openscope
      3: openlogger
    stop_reasons:
      0: normal
      1: forced
      2: error
      3: overflow
      4: unknown
  </code></pre>