import type { VariableType } from "../types.js"; import type { SourceLocation } from "../types/base.js"; import type { ScopeInfo, TypeCheckerContext } from "./types.js"; /** * Computes the value type of every expression-position `match`: the widened * union of its `matchYield` value types. Runs after buildScopes + buildFlowGraphs * (so scope types and flow-sensitive narrowing are available) and before * checkScopes (so consumers can read `ctx.matchExprTypes`). * * Per scope, match ids are processed in DESCENDING order: inner matches have * higher ids (the lowerer recurses inner-last), and an outer match's yield may * be `varRef(__matchval_)`. Synthing that ref goes through the * `__matchval_` hook in the synthesizer, which reads the already-computed inner * entry — so descending order makes the recursion resolve bottom-up. * * After the table is built for ALL scopes, a second pass patches the recorded * scope type of every consumer variable (`const x = match(...)` → tagged * `matchExprSource`) to the match's value type when the assignment had no * explicit annotation. The two passes are separate so a consumer whose match * yields live in another scope (a module-level `const x = match(...)` lowers to * a call into a synthesized init function) still resolves regardless of order. buildScopes ran before this pass and synthed the `__matchval_` * ref to "any" (the table was empty then), so without this patch a downstream * `const y = x` would see `x` as "any". */ export declare function computeMatchExprTypes(scopes: ScopeInfo[], ctx: TypeCheckerContext): void; /** * CHECKED-position assignability for an expression-position `match`: check EACH * arm's `matchYield` value against `expected` using the yield's UNWIDENED type, * anchoring any error on the offending arm's value. This is what makes * `const c: Category = match(x) { "go" => "a"; _ => "b" }` (with * `type Category = "a" | "b"`) type-check — the widened union `string` recorded * in `matchExprTypes` would falsely reject it. Use this whenever the consumer * supplies an expected type (annotation or declared return type); fall back to * the widened `matchExprTypes` union only in synthesis (unannotated) positions. * No-op if the match id has no recorded yields. */ export declare function checkMatchExprYields(matchId: number, expected: VariableType, context: string, ctx: TypeCheckerContext, fallbackLoc: SourceLocation | undefined): void;