/** * A17: a List literal used as a tuple. A List holds one element type, so a * mixed literal publishes a union and every value read back out of it is that * union; the record is the spelling this language has for a fixed group of * differently typed values. * * D115 §三 / D114 R1f: one family of `advisories.ts`. */ import { type Expression } from "../../ast.ts"; import { type ValueType } from "../../types.ts"; import { type AdvisoryHost } from "./roster.ts"; export declare class TupleAdvisories { private readonly host; constructor(host: AdvisoryHost); /** * D114 ⑤ — A17: Python's `return a, b` and JavaScript's `return [a, b]` both * land here as a List literal whose elements are of different types. Vel * accepts it and types it `List`, so the author does not * learn anything until a member read three lines later reports "no common * field". The record is the spelling this language has for a fixed group of * differently typed values, and it gives each value a name. * * The admission is deliberately narrow, at D89's near-zero-false-positive * bar. Two or more written elements, every one of them in a primitive * category — string, number, bool, or enum — and at least two different * categories among them. A `null` element is ignored rather than counted: * `["a", null]` is a `List`, which is one element type. Anything * else in the literal — a spread, a record, a class, a collection, a * function, a union, `unknown` — keeps the whole literal silent, because a * heterogeneous list of records is a real data shape and this advisory may * not guess. Two different enums are one category, so `[Kind.a, Status.b]` * is silent as well. * * The literal must also stand where nothing declared its element type. An * annotated binding, a declared result, an annotated field, and an argument * to a `List` parameter all arrive here with a contextual * type: the author wrote the union, and the advisory has nothing to say. An * unannotated binding, a body-inferred `return`, and an arrow body with no * contextual function type arrive with none. * * There is no mechanical fix. The rewrite has to invent a field name for * each value, which is a judgement, exactly as A7's is. */ adviseTupleShapedListLiteral(expression: Extract, contextualType: ValueType, writtenElementTypes: readonly ValueType[], element: ValueType): void; /** * A17's element classification. Answers the primitive category an element * contributes, `""` for an element that is ignored (`null`, and the `null` * arm of an optional), and `null` for one that keeps the whole literal * silent. */ private tupleElementCategory; /** The record an A17 literal would be written as, or null when it is too long to quote. */ private tupleRecordSpelling; /** The field name a value suggests: the name it already reads, else its category. */ private tupleFieldName; /** One written expression, quoted for a message and clipped when it runs long. */ private boundedSourceQuote; } //# sourceMappingURL=tuples.d.ts.map