All files / transpiler/constants UNRESOLVED_DIMENSION.ts

100% Statements 1/1
100% Branches 0/0
100% Functions 0/0
100% Lines 1/1

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27                                              97x      
/**
 * Issue #1159: placeholder for an array dimension whose size is not known at
 * compile time (a non-constant expression, or a const from a file not yet
 * collected).
 *
 * The slot is kept rather than omitted so that dimension `i` always
 * corresponds to subscript `i`. Dropping an unresolvable dimension shifts
 * every dimension after it, which would make `TypeValidator.checkArrayBounds`
 * validate an index against the wrong bound — e.g. `u8[N][4] grid` would check
 * `grid[i]` against 4.
 *
 * `0` is the value because `checkArrayBounds` already skips non-positive
 * dimensions, and `ArrayDimensionParser.parseDimensions` established the
 * same convention. It means "size unknown, cannot validate" — never "size
 * zero". A dimension that IS statically known must never be recorded as this;
 * conflating the two is what silently disabled bounds checking for hex-sized
 * arrays before #1159.
 *
 * Distinct from the `""` that `ArrayDimensionText` records for an unsized
 * `[]`: that says the source declared no size, and renders back as `[]`. This
 * says the source declared a size that could not be folded. See the note in
 * `src/utils/ArrayDimensionText.ts`.
 */
const UNRESOLVED_DIMENSION = 0;
 
export default UNRESOLVED_DIMENSION;