/** * The vocabulary every cluster needs when it meets a function declaration: the * shape a declaration has to have to be analyzable, the frame a body's returns * are collected into, and the placeholder that stands for a result still being * inferred. * * D114 R1d: these were top-level declarations of `analyzer.ts`, read by the * class cluster (a method is a function declaration), by the module cluster (an * exported `def` is one) and by the analyzer's own dispatch. They move here so * none of those has to import the facade it is part of. * `inferredResultPlaceholderType` is a published name of * `@velarscript/compiler`, so `analyzer.ts` re-exports it. */ import { type FunctionDeclaration, type TypeParameterDeclaration } from "../ast.ts"; import { type Span } from "../source.ts"; import { type ValueType } from "../types.ts"; export interface ReturnContext { readonly expected: ValueType; readonly inferredReturns: ValueType[] | null; /** * D58 correction 2: the results a body returns while an annotation is * written, collected only where that annotation is the `-> null` rule 139 * refuses. `inferredReturns` is null in that case — the declared result is * the contract — so the deletion's precondition needs its own observation. */ readonly observedReturns: ValueType[] | null; readonly declarationKind: string; /** * D85 rule 209: a `return []` that VEL4039 already reported contributes * `invalidType` so no caller reports the same hole again. That makes the * collected result invalid, which is otherwise a convergence failure — but * here the author has already been told exactly what to write, so VEL4025 * would be the second report of one mistake. */ unsettledResult?: boolean; /** * D85 rule 209: the result keys of the local functions this body returns the * result of. A callee's hole can be reported after its caller is analyzed, * so a call contributes a cause here and the whole module decides. */ resultHoleCauses?: Set; } export interface AnalyzableFunctionDeclaration { readonly kind: string; readonly name: string; readonly typeParameters?: readonly TypeParameterDeclaration[]; readonly parameters: FunctionDeclaration["parameters"]; readonly returnType: FunctionDeclaration["returnType"]; readonly resultAnnotationSpan?: FunctionDeclaration["resultAnnotationSpan"]; readonly signatureSpan: FunctionDeclaration["signatureSpan"]; readonly body: FunctionDeclaration["body"]; readonly span: Span; readonly asynchronous?: boolean; readonly exported?: boolean; readonly private?: boolean; } export declare const inferredResultPlaceholderType: ValueType; export declare function containsInferredResultPlaceholder(type: ValueType): boolean; export declare function sameInferredResult(left: ValueType, right: ValueType): boolean; /** * D64 rule 163: the scope in this sentence is load-bearing, and it is also why * the sentence is written once instead of in each of the four declaration * positions that report it. A *declaration* carries `async`, so its result * annotation names the resolved value; a function *type* carries no `async` * and describes the value the call hands back, which is a Promise. Stated * without "in a declaration" this reads as a rule about the whole language, * and an author who obeys it in a function type is refused by VEL4001 for * doing what it said — `asyncResultSpellingGuidance` is the other half. */ export declare const asyncResultAnnotationMessage = "An async result annotation in a declaration names the resolved value; write '-> T', not '-> Promise'"; /** * A class declared in an `extern module` block carries the `js:` identity * scheme; a VelarScript class carries `velar:`. The prefix is the only thing * that separates "this name is not a class" from "this class lives on the * other side of the bridge" (CLS-I4). */ export declare function isExternClassIdentity(identity: string | null): boolean; //# sourceMappingURL=functions.d.ts.map