All files / utils/constants PROPERTY_NAMES.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 28 29 30 31 32 33 34 35 36 37                                            80x                            
/**
 * Every property name the language defines on a value's shape or storage.
 *
 * #1322: three rules read this list, from two directions, and they must agree.
 *
 * - ADR-058's four shape properties (`bit_length`, `byte_length`,
 *   `element_count`, `char_count`) and ADR-045's two storage ones (`capacity`,
 *   `size`) are what `LengthPropertyAnalyzer` OWNS -- it decides whether each
 *   is used on a subject that has it.
 * - `length` is here because it is a NAME the language knows and rejects
 *   (ADR-058 deprecated it). Leaving it out would make it look like an
 *   ordinary member and be reported as an unknown one.
 * - ADR-034's unknown-field rule reads the same list to know what is NOT a
 *   bitmap field. Before it was shared, `flags.bit_length` reported
 *   "Unknown bitmap field 'bit_length'" while ADR-058 defined it; with
 *   `capacity` added and this list not, `flags.capacity` would have reported
 *   the same thing INSTEAD of "only available on strings", which is the
 *   message that tells the author what is wrong.
 *
 * One list, so a property added to the language cannot be a shape rule in one
 * analyzer and an unknown member in another.
 */
const PROPERTY_NAMES: ReadonlySet<string> = new Set([
  // ADR-058, shape
  "bit_length",
  "byte_length",
  "element_count",
  "char_count",
  // ADR-045, string storage
  "capacity",
  "size",
  // ADR-058, deprecated and rejected
  "length",
]);
 
export default PROPERTY_NAMES;