eutaxy 0.17.2 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -12
- package/dist/aws.d.mts +2 -2
- package/dist/aws.mjs +3 -2
- package/dist/aws.mjs.map +1 -1
- package/dist/bin.mjs +1 -1
- package/dist/check-zkHLdWyf.mjs +1281 -0
- package/dist/check-zkHLdWyf.mjs.map +1 -0
- package/dist/cli-CNAKqV9R.mjs +297 -0
- package/dist/cli-CNAKqV9R.mjs.map +1 -0
- package/dist/cli.d.mts.map +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/cloudflare.d.mts +56 -5
- package/dist/cloudflare.d.mts.map +1 -1
- package/dist/cloudflare.mjs +6417 -3
- package/dist/cloudflare.mjs.map +1 -0
- package/dist/{delivery-invariants-DO3j1mmD.mjs → delivery-invariants-BJDck0K8.mjs} +2 -2
- package/dist/{delivery-invariants-DO3j1mmD.mjs.map → delivery-invariants-BJDck0K8.mjs.map} +1 -1
- package/dist/{delivery-invariants-D7DI7i8x.d.mts → delivery-invariants-C3GXJIbg.d.mts} +2 -2
- package/dist/{delivery-invariants-D7DI7i8x.d.mts.map → delivery-invariants-C3GXJIbg.d.mts.map} +1 -1
- package/dist/draft-DEUDffHa.mjs +467 -0
- package/dist/draft-DEUDffHa.mjs.map +1 -0
- package/dist/{src-fxWc6oGc.mjs → generate-TBJM3-2P.mjs} +3 -574
- package/dist/generate-TBJM3-2P.mjs.map +1 -0
- package/dist/index.d.mts +45 -37
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +7 -4
- package/dist/index.mjs.map +1 -1
- package/dist/install-DkzpGA5D.mjs +611 -0
- package/dist/install-DkzpGA5D.mjs.map +1 -0
- package/dist/{explore-CkKiOuz6.d.mts → ir-KpC2epGn.d.mts} +88 -53
- package/dist/ir-KpC2epGn.d.mts.map +1 -0
- package/dist/keys-xtanNmuR.mjs +111 -0
- package/dist/keys-xtanNmuR.mjs.map +1 -0
- package/dist/mcp-B64Ko6y7.mjs +539 -0
- package/dist/mcp-B64Ko6y7.mjs.map +1 -0
- package/dist/{platform-D4hlJjm3.d.mts → platform-Cs9V9t2k.d.mts} +92 -11
- package/dist/platform-Cs9V9t2k.d.mts.map +1 -0
- package/dist/pool-CXN4CwGY.mjs +61 -0
- package/dist/pool-CXN4CwGY.mjs.map +1 -0
- package/dist/{provers-DS44OeEm.mjs → provers-D8VaY_OM.mjs} +18 -2
- package/dist/provers-D8VaY_OM.mjs.map +1 -0
- package/dist/reader-B9FSoEYW.mjs +1 -0
- package/dist/reader-Cz6_bLf6.mjs +3774 -0
- package/dist/reader-Cz6_bLf6.mjs.map +1 -0
- package/dist/report-_Vzavqg0.mjs +310 -0
- package/dist/report-_Vzavqg0.mjs.map +1 -0
- package/dist/src-B2DpVbMN.mjs +2 -0
- package/dist/src-BFGTvuA_.mjs +1235 -0
- package/dist/src-BFGTvuA_.mjs.map +1 -0
- package/dist/src-BtLZPRyG.mjs +120 -0
- package/dist/src-BtLZPRyG.mjs.map +1 -0
- package/dist/src-CB8DcvsK.mjs +1 -0
- package/dist/src-COuquJvI.mjs +269 -0
- package/dist/src-COuquJvI.mjs.map +1 -0
- package/dist/src-Chn-m_r1.mjs +1082 -0
- package/dist/src-Chn-m_r1.mjs.map +1 -0
- package/dist/src-DwYD3QQJ.mjs +346 -0
- package/dist/src-DwYD3QQJ.mjs.map +1 -0
- package/dist/{src-D_hHC_-3.mjs → src-Dx4QvrQb.mjs} +945 -548
- package/dist/src-Dx4QvrQb.mjs.map +1 -0
- package/dist/toolchain-DWfymxAJ.mjs +80 -0
- package/dist/toolchain-DWfymxAJ.mjs.map +1 -0
- package/dist/verdict-evEM5Gxx.mjs +12 -0
- package/dist/verdict-evEM5Gxx.mjs.map +1 -0
- package/package.json +4 -1
- package/dist/cli-B0Gs2mhT.mjs +0 -9445
- package/dist/cli-B0Gs2mhT.mjs.map +0 -1
- package/dist/explore-CkKiOuz6.d.mts.map +0 -1
- package/dist/platform-D4hlJjm3.d.mts.map +0 -1
- package/dist/provers-DS44OeEm.mjs.map +0 -1
- package/dist/src-D_hHC_-3.mjs.map +0 -1
- package/dist/src-fxWc6oGc.mjs.map +0 -1
- package/dist/workerd-DhrzU6AZ.mjs +0 -6300
- package/dist/workerd-DhrzU6AZ.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reader-Cz6_bLf6.mjs","names":[],"sources":["../../prover/src/reader/tree.ts","../../prover/src/reader/binders.ts","../../prover/src/reader/compiler.ts","../../prover/src/reader/restrict.ts","../../prover/src/reader/rebinding.ts","../../prover/src/reader/typing.ts","../../prover/src/reader/declarations.ts","../../prover/src/reader/narrowing.ts","../../prover/src/reader/expressions.ts","../../prover/src/reader/rename.ts","../../prover/src/reader/inline.ts","../../prover/src/reader/types.ts","../../prover/src/reader/subset.ts","../../prover/src/reader/engine.ts","../../prover/src/reader/specs.ts"],"sourcesContent":["/**\n * The subset's tree: its types (`SubsetType`, records, tagged unions),\n * its expressions (`Expr`), and a module as read (`SubsetModule`: the\n * functions the subset takes and, for the others, why not), with what\n * depends on the tree alone: `describe`, `children`, `callees`, the list\n * kinds.\n * Every other module of the reader imports this one, and it imports none\n * of them.\n */\n\nexport class OutsideSubset extends Error {\n readonly line: number;\n constructor(message: string, line: number) {\n super(message);\n this.line = line;\n }\n}\n\nexport type SubsetType =\n | { readonly kind: \"int\" }\n | { readonly kind: \"bool\" }\n | { readonly kind: \"string\" }\n | { readonly kind: \"record\"; readonly name: string }\n /** `T | null`. */\n | { readonly kind: \"nullable\"; readonly inner: SubsetType }\n /** A tagged union of records declared as a type alias; its members are records of the module. */\n | { readonly kind: \"union\"; readonly name: string }\n /** The type of the literal `null` itself, which only a nullable type accepts. */\n | { readonly kind: \"null\" }\n /** `readonly T[]` or `T[]`: a list of values of one type (Lean's `List`). */\n | { readonly kind: \"list\"; readonly element: SubsetType }\n /** The element type of `[]`, which fits in a list of any type. */\n | { readonly kind: \"nothing\" };\n\nexport interface Field {\n readonly name: string;\n readonly type: SubsetType;\n /** The one value a literal-typed field holds (`ok: true`, `type: \"locked\"`): a union member's tag. */\n readonly literal?: string | boolean;\n}\n\nexport interface RecordType {\n readonly name: string;\n readonly fields: readonly Field[];\n /**\n * The tagged unions this record is a member of, in the order they were\n * read: `Err<E>` is one in `Result<A, E>` and in `Result<B, E>`. A member\n * written inline in a union is named `<union>.<tag>` after the first.\n */\n readonly unions?: readonly string[];\n}\n\n/** Whether a record is a member of a union. */\nexport function isMember(record: RecordType | undefined, union: string): boolean {\n return record?.unions?.includes(union) ?? false;\n}\n\n/** A tagged union: records told apart by one field, the tag, which holds a different literal in each. */\nexport interface UnionType {\n readonly name: string;\n readonly tag: string;\n /** The member records, in declaration order, by their tag's value. */\n readonly members: readonly { readonly tag: string | boolean; readonly record: string }[];\n}\n\nexport type BinaryOp =\n | \"+\"\n | \"-\"\n | \"*\"\n | \"/\"\n | \"<\"\n | \"<=\"\n | \">\"\n | \">=\"\n | \"===\"\n | \"!==\"\n | \"&&\"\n | \"||\";\n\nexport type Expr =\n | { readonly kind: \"int\"; readonly value: string }\n | { readonly kind: \"bool\"; readonly value: boolean }\n | { readonly kind: \"string\"; readonly value: string }\n | { readonly kind: \"null\" }\n | { readonly kind: \"var\"; readonly name: string }\n /** In `body`, `name` (a nullable in scope) stands for its non-null value: inserted where a null check guards. */\n | { readonly kind: \"narrow\"; readonly name: string; readonly body: Expr }\n /** In `body`, `name` (a union in scope) is its member `member`: inserted where a test of the union's tag guards. */\n | {\n readonly kind: \"narrowTag\";\n readonly name: string;\n readonly member: string;\n readonly body: Expr;\n }\n | { readonly kind: \"neg\"; readonly operand: Expr }\n | { readonly kind: \"not\"; readonly operand: Expr }\n /** `Number.isInteger(e)`: always true of an integer in the engines' integer model, the real predicate on doubles. */\n | { readonly kind: \"isInteger\"; readonly operand: Expr }\n /** `Math.floor(e)`: rounding toward negative infinity on doubles; the identity on the integers. */\n | { readonly kind: \"floor\"; readonly operand: Expr }\n | { readonly kind: \"binary\"; readonly op: BinaryOp; readonly left: Expr; readonly right: Expr }\n | { readonly kind: \"cond\"; readonly test: Expr; readonly ifTrue: Expr; readonly ifFalse: Expr }\n | { readonly kind: \"call\"; readonly callee: string; readonly args: readonly Expr[] }\n | { readonly kind: \"field\"; readonly object: Expr; readonly field: string }\n | {\n readonly kind: \"record\";\n readonly fields: readonly { readonly name: string; readonly value: Expr }[];\n /** The type its context gives the literal (a declared return type, a const annotation, a parameter), as the compiler sees it: a record, or the union a member is picked from. */\n readonly type?: SubsetType;\n }\n | {\n readonly kind: \"let\";\n readonly name: string;\n readonly value: Expr;\n readonly body: Expr;\n /** The `const`'s annotation, when it has one: the binding's type, whatever the initializer's. */\n readonly type?: SubsetType;\n }\n /** `[a, b]`, or `[a, b, ...rest]` with the spread last. `xs.length` is a `field` read on a list. */\n | { readonly kind: \"list\"; readonly items: readonly Expr[]; readonly rest?: Expr }\n /** `xs.slice(1)`: every element but the first. */\n | { readonly kind: \"tail\"; readonly list: Expr }\n /** `xs[0] ?? fallback`: the first element, or the fallback for an empty list. */\n | { readonly kind: \"headOr\"; readonly list: Expr; readonly fallback: Expr }\n /** `xs.map`, `xs.flatMap`, `xs.every` or `xs.some` with `(item, index?) => body`. */\n | {\n readonly kind: \"iterate\";\n readonly op: \"map\" | \"flatMap\" | \"every\" | \"some\";\n readonly list: Expr;\n readonly item: string;\n readonly index?: string;\n readonly body: Expr;\n }\n /** `xs.reduce((acc, item) => body, init)`: a left fold. */\n | {\n readonly kind: \"fold\";\n readonly list: Expr;\n readonly acc: string;\n readonly item: string;\n readonly body: Expr;\n readonly init: Expr;\n };\n\nexport interface Param {\n readonly name: string;\n readonly type: SubsetType;\n}\n\nexport interface SubsetFunction {\n readonly name: string;\n readonly params: readonly Param[];\n readonly returns: SubsetType;\n readonly body: Expr;\n /** 1-based line of the declaration. */\n readonly line: number;\n /** Offset of the `(` opening its parameters: the declaration's identity, as the spec extractor records it. */\n readonly offset: number;\n /**\n * For a recursive function, the list parameter it recurses on (its\n * index): the body tests that list's length against 0 first, and every\n * call to itself, in the other branch, passes that list's slice(1).\n */\n readonly structural?: number;\n}\n\n/** A function the subset does not take, and why. */\nexport interface OutsideFunction {\n readonly name: string;\n readonly line: number;\n readonly message: string;\n}\n\nexport interface SubsetModule {\n readonly records: readonly RecordType[];\n readonly unions: readonly UnionType[];\n /** The functions in the subset, in source order, callees before callers. */\n readonly functions: readonly SubsetFunction[];\n /** The module's other functions: outside the subset themselves, or calling one that is. */\n readonly outside: readonly OutsideFunction[];\n}\n\n/** Whether a string holds a surrogate code unit without its pair: no Lean character corresponds to it. */\nexport function hasLoneSurrogate(s: string): boolean {\n return /[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?<![\\uD800-\\uDBFF])[\\uDC00-\\uDFFF]/.test(s);\n}\n\n/** A type, for messages. */\nexport function describe(t: SubsetType): string {\n switch (t.kind) {\n case \"record\":\n case \"union\":\n return t.name;\n case \"nullable\":\n return `${describe(t.inner)} | null`;\n case \"list\":\n return t.element.kind === \"nullable\"\n ? `(${describe(t.element)})[]`\n : `${describe(t.element)}[]`;\n default:\n return t.kind;\n }\n}\n\n/** The functions an expression calls. */\nexport function callees(e: Expr, out = new Set<string>()): Set<string> {\n switch (e.kind) {\n case \"int\":\n case \"bool\":\n case \"string\":\n case \"null\":\n case \"var\":\n return out;\n case \"narrow\":\n case \"narrowTag\":\n return callees(e.body, out);\n case \"neg\":\n case \"not\":\n case \"isInteger\":\n case \"floor\":\n return callees(e.operand, out);\n case \"binary\":\n callees(e.left, out);\n return callees(e.right, out);\n case \"cond\":\n callees(e.test, out);\n callees(e.ifTrue, out);\n return callees(e.ifFalse, out);\n case \"call\":\n out.add(e.callee);\n for (const a of e.args) callees(a, out);\n return out;\n case \"field\":\n return callees(e.object, out);\n case \"record\":\n for (const f of e.fields) callees(f.value, out);\n return out;\n case \"let\":\n callees(e.value, out);\n return callees(e.body, out);\n case \"list\":\n for (const x of e.items) callees(x, out);\n return e.rest ? callees(e.rest, out) : out;\n case \"tail\":\n return callees(e.list, out);\n case \"headOr\":\n callees(e.list, out);\n return callees(e.fallback, out);\n case \"iterate\":\n callees(e.list, out);\n return callees(e.body, out);\n case \"fold\":\n callees(e.list, out);\n callees(e.init, out);\n return callees(e.body, out);\n }\n}\n\n/** An expression's direct subexpressions. */\nexport function children(e: Expr): Expr[] {\n switch (e.kind) {\n case \"int\":\n case \"bool\":\n case \"string\":\n case \"null\":\n case \"var\":\n return [];\n case \"narrow\":\n case \"narrowTag\":\n return [e.body];\n case \"neg\":\n case \"not\":\n case \"isInteger\":\n case \"floor\":\n return [e.operand];\n case \"binary\":\n return [e.left, e.right];\n case \"cond\":\n return [e.test, e.ifTrue, e.ifFalse];\n case \"call\":\n return [...e.args];\n case \"field\":\n return [e.object];\n case \"record\":\n return e.fields.map((f) => f.value);\n case \"let\":\n return [e.value, e.body];\n case \"list\":\n return [...e.items, ...(e.rest ? [e.rest] : [])];\n case \"tail\":\n return [e.list];\n case \"headOr\":\n return [e.list, e.fallback];\n case \"iterate\":\n return [e.list, e.body];\n case \"fold\":\n return [e.list, e.init, e.body];\n }\n}\n\n/** An expression only lists bring. */\nexport type ListExpr = Extract<Expr, { kind: \"list\" | \"tail\" | \"headOr\" | \"iterate\" | \"fold\" }>;\n\n/** The expression kinds only lists bring, for an engine that does not take them. */\nexport const listKinds: ReadonlySet<Expr[\"kind\"]> = new Set<ListExpr[\"kind\"]>([\n \"list\",\n \"tail\",\n \"headOr\",\n \"iterate\",\n \"fold\",\n]);\n\n/** Whether an expression is one only lists bring (a type guard over `listKinds`). */\nexport const isListExpr = (e: Expr): e is ListExpr => listKinds.has(e.kind);\n","/**\n * A spec's binder type read into the subset's type, once for every\n * engine: `number`, `boolean` and `string` to their own, a literal to its\n * primitive, a union of string literals to a string, a declared record to\n * the module's record of that name, `T | null` to the nullable type over\n * `T`, a union of records to the one declared union whose members match,\n * an array to a list. What an engine does not take is its `BinderRule`:\n * it names the reason, and the binder is refused with it where the engine\n * would have refused it itself, so a user reads the engine's own words.\n * Bigint, `undefined` and what the spec reader could not read are outside\n * for every engine.\n */\n\nimport { describeType, type SpecType } from \"@eutaxy/spec\";\nimport {\n OutsideSubset,\n type RecordType,\n type SubsetModule,\n type SubsetType,\n type UnionType,\n} from \"./tree.ts\";\n\n/**\n * What an engine does not take of binder types, each with why (the text\n * after `binder <name> over <type>: `). Absent: the engine takes it.\n */\nexport interface BinderRule {\n /** A union with `null` or `undefined` among its members. Checked before `union`. */\n readonly nullable?: string;\n /** Any union other than one of string literals, which every engine with this rule still reads as a string. */\n readonly union?: string;\n /** An array. */\n readonly array?: string;\n}\n\nconst fail: (message: string) => never = (message) => {\n throw new OutsideSubset(message, 0);\n};\n\n/** The subset type a binder ranges over under an engine's rule, or `OutsideSubset` with why. */\nexport function readBinderType(\n name: string,\n t: SpecType,\n module: SubsetModule,\n rule: BinderRule,\n): SubsetType {\n const over = `binder ${name} over ${describeType(t)}`;\n switch (t.kind) {\n case \"number\":\n return { kind: \"int\" };\n case \"boolean\":\n return { kind: \"bool\" };\n case \"string\":\n return { kind: \"string\" };\n case \"literal\":\n if (typeof t.value === \"string\") return { kind: \"string\" };\n if (typeof t.value === \"boolean\") return { kind: \"bool\" };\n return { kind: \"int\" };\n case \"bigint\":\n // A BigInt passed to a function over number throws on the first mixed operation in JavaScript.\n return fail(`binder ${name} over bigint: the subset has no bigint`);\n case \"union\": {\n const strings = (ms: readonly SpecType[]): boolean =>\n ms.every((m) => m.kind === \"literal\" && typeof m.value === \"string\");\n if (rule.union !== undefined) {\n // An engine that takes no union still takes a union of string literals, as a string.\n if (strings(t.members)) return { kind: \"string\" };\n if (\n rule.nullable !== undefined &&\n t.members.some((m) => m.kind === \"null\" || m.kind === \"undefined\")\n )\n return fail(`${over}: ${rule.nullable}`);\n return fail(`${over}: ${rule.union}`);\n }\n const nulls = t.members.filter((m) => m.kind === \"null\");\n const undefineds = t.members.some((m) => m.kind === \"undefined\");\n // An engine that takes no nullable type says so for `undefined` as for `null`.\n if (rule.nullable !== undefined && (nulls.length > 0 || undefineds))\n return fail(`${over}: ${rule.nullable}`);\n if (undefineds) return fail(`${over}: undefined is not in the subset (null is)`);\n const rest = t.members.filter((m) => m.kind !== \"null\");\n let inner: SubsetType;\n if (strings(rest)) inner = { kind: \"string\" };\n else if (rest.every((m) => m.kind === \"literal\" && typeof m.value === \"boolean\"))\n inner = { kind: \"bool\" };\n else if (rest.length === 1) inner = readBinderType(name, rest[0] as SpecType, module, rule);\n else if (rest.every((m) => m.kind === \"record\")) {\n const union = findUnion(\n rest as readonly Extract<SpecType, { kind: \"record\" }>[],\n module,\n rule,\n );\n if (!union)\n return fail(`${over}: no one union the module declares has exactly these members`);\n inner = { kind: \"union\", name: union.name };\n } else return fail(`${over}: a union the subset does not read`);\n return nulls.length > 0 ? { kind: \"nullable\", inner } : inner;\n }\n case \"record\":\n if (t.name !== undefined && module.records.some((r) => r.name === t.name))\n return { kind: \"record\", name: t.name };\n return fail(\n `${over}: ${t.name === undefined ? \"an inline record type\" : `record type ${t.name} is outside the subset`}`,\n );\n case \"null\":\n case \"undefined\":\n return fail(`binder ${name} over ${t.kind}`);\n case \"array\":\n if (rule.array !== undefined) return fail(`${over}: ${rule.array}`);\n return { kind: \"list\", element: readBinderType(name, t.element, module, rule) };\n case \"unknown\":\n return fail(`binder ${name} over ${t.text}, which the reader could not read`);\n }\n}\n\n/**\n * The one declared union these member types are, compared field by field\n * and type by type: a field holding one literal is that literal in the\n * union's member, a union of literals is a field of no literal, and\n * everything else reads to the field's own type. A record may be a member\n * of several unions, so tags and field names alone could name the wrong\n * one; when more than one union fits, none is chosen.\n */\nfunction findUnion(\n members: readonly Extract<SpecType, { kind: \"record\" }>[],\n module: SubsetModule,\n rule: BinderRule,\n): UnionType | undefined {\n const recordOf = (name: string) => module.records.find((r) => r.name === name);\n // A nested record is compared by its fields, not its name: the spec reader and the subset reader\n // may name one inline type differently (`Extract<U, …>` against `U.a`).\n const recordFits = (sm: Extract<SpecType, { kind: \"record\" }>, rec: RecordType): boolean =>\n sm.fields.length === rec.fields.length &&\n rec.fields.every((f) => {\n const sf = sm.fields.find((x) => x.name === f.name);\n return sf !== undefined && fieldFits(sf.type, f);\n });\n const typeFits = (sf: SpecType, t: SubsetType): boolean => {\n if (t.kind === \"record\") {\n const rec = recordOf(t.name);\n return sf.kind === \"record\" && rec !== undefined && recordFits(sf, rec);\n }\n if (t.kind === \"nullable\" && sf.kind === \"union\" && sf.members.some((m) => m.kind === \"null\")) {\n const rest = sf.members.filter((m) => m.kind !== \"null\");\n const inner: SpecType =\n rest.length === 1 ? (rest[0] as SpecType) : { kind: \"union\", members: rest };\n return typeFits(inner, t.inner);\n }\n if (t.kind === \"union\") {\n const u = module.unions.find((x) => x.name === t.name);\n if (!u || sf.kind !== \"union\" || sf.members.length !== u.members.length) return false;\n return u.members.every((m) => {\n const rec = recordOf(m.record);\n return (\n rec !== undefined && sf.members.some((sm) => sm.kind === \"record\" && recordFits(sm, rec))\n );\n });\n }\n try {\n return JSON.stringify(readBinderType(\"field\", sf, module, rule)) === JSON.stringify(t);\n } catch (err) {\n if (err instanceof OutsideSubset) return false;\n throw err;\n }\n };\n function fieldFits(sf: SpecType, f: RecordType[\"fields\"][number]): boolean {\n if (f.literal !== undefined) return sf.kind === \"literal\" && sf.value === f.literal;\n if (sf.kind === \"literal\") return false;\n return typeFits(sf, f.type);\n }\n const fitting = module.unions.filter((u) => {\n if (u.members.length !== members.length) return false;\n return u.members.every((m) => {\n const rec = recordOf(m.record);\n return rec !== undefined && members.some((sm) => recordFits(sm, rec));\n });\n });\n return fitting.length === 1 ? fitting[0] : undefined;\n}\n","/**\n * The TypeScript compiler, through its API (7.1): one compiler process per\n * Node process, started on first use; a program per read, over an\n * in-memory layer holding the files being read on top of the host's own\n * files, so imports resolve as the user's compiler resolves them; a\n * standalone source file for text that is not a module (a spec file's\n * arrow, read back from its text). Every handle the compiler process\n * holds for a read is released when the read ends. Nothing else in Eutaxy\n * imports the compiler API: a change to it lands here.\n */\n\nimport {\n type FunctionLikeBase,\n type Identifier,\n ModifierFlags,\n type ModifiersBase,\n type Node,\n NodeFlags,\n type SourceFile,\n SyntaxKind,\n type VariableDeclarationList,\n} from \"typescript/ast\";\nimport { createFileSystemLayer } from \"typescript/fs\";\nimport { API, type Checker, DiagnosticCategory, type Program } from \"typescript/sync\";\n\nlet api: API | undefined;\n\nfunction compiler(): API {\n api ??= new API({});\n return api;\n}\n\n/** Stop the compiler process; the next read starts another. */\nexport function closeCompiler(): void {\n api?.close();\n api = undefined;\n}\n\n/**\n * The options every read compiles under: strict, the latest language\n * level, bundler-style resolution with `.ts` imports allowed, and the\n * standard library alone (`types: []`), so a module's own types resolve\n * and nothing is emitted. The user's configuration is not read: a type\n * Eutaxy cannot resolve under these options is reported unknown, never\n * guessed.\n */\nconst options = {\n strict: true,\n target: 99, // ScriptTarget.ESNext\n module: 99, // ModuleKind.ESNext\n moduleResolution: 100, // ModuleResolutionKind.Bundler\n allowImportingTsExtensions: true,\n noEmit: true,\n skipLibCheck: true,\n types: [] as string[],\n lib: [\"es2023\"],\n};\n\n/** A file given to a read: its path, under which imports resolve, and its text, which stands in for the file on disk. */\nexport interface InputFile {\n readonly path: string;\n readonly text: string;\n}\n\n/** A program over the input files, with its checker. */\nexport interface Opened {\n readonly program: Program;\n readonly checker: Checker;\n /** The source file of an input path. */\n readonly file: (path: string) => SourceFile;\n /** The first parse error of an input file, if any. */\n readonly parseError: (path: string) => { line: number; message: string } | undefined;\n /** The compiler's errors in a file of the program: text ranges (offsets into the file), with the message and its line. */\n readonly typeErrors: (path: string) => readonly CompilerError[];\n /**\n * Whether an identifier names the global of its name: the compiler\n * resolves it to a symbol declared in its default library alone\n * (`lib.*.d.ts`). A declaration, import or block-scoped shadow of the\n * name in scope, a global declared by the project's own declaration\n * files, or a name the compiler cannot resolve is not; a type-only\n * import of the name is, since the compiler resolves a value past it,\n * and so is an interface augmentation of its type (`declare global {\n * interface Number { … } }`), which changes no value.\n */\n readonly standardGlobal: (id: Identifier) => boolean;\n}\n\n/** One compiler error in a file: its text range, message and 1-based line. */\nexport interface CompilerError {\n readonly pos: number;\n readonly end: number;\n readonly message: string;\n readonly line: number;\n}\n\n/** Run `fn` over a program whose root files are the inputs, released afterwards. */\nexport function withProgram<T>(files: readonly InputFile[], fn: (opened: Opened) => T): T {\n const snapshot = compiler().createSnapshot({\n fileSystem: createFileSystemLayer(files.map((f) => [f.path, f.text] as const)),\n createPrograms: [{ rootFiles: files.map((f) => f.path), compilerOptions: options }],\n });\n try {\n const program = snapshot.operation.createdPrograms[0];\n const checker = program.getProject().checker;\n const file = (path: string): SourceFile => {\n const sf = program.getSourceFile(path);\n if (!sf) throw new Error(`the compiler holds no source file for ${path}`);\n return sf;\n };\n const parseError = (path: string) => {\n const first = program.getSyntacticDiagnostics(path)[0];\n return first\n ? { line: (first.startPosition?.line ?? 0) + 1, message: first.text }\n : undefined;\n };\n const errors = new Map<string, readonly CompilerError[]>();\n const typeErrors = (path: string) => {\n let found = errors.get(path);\n if (!found) {\n found = program\n .getSemanticDiagnostics(path)\n .filter((d) => d.category === DiagnosticCategory.Error)\n .map((d) => ({\n pos: d.pos,\n end: d.end,\n message: d.text,\n line: (d.startPosition?.line ?? 0) + 1,\n }));\n errors.set(path, found);\n }\n return found;\n };\n // Answers by symbol: the global `Math` is one symbol however often it is named. Interface and\n // type alias declarations merge into a symbol without touching its value, so only the others decide.\n const standard = new Map<number, boolean>();\n const typeOnly = new Set([SyntaxKind.InterfaceDeclaration, SyntaxKind.TypeAliasDeclaration]);\n const standardGlobal = (id: Identifier): boolean => {\n const symbol = checker.getSymbolAtLocation(id);\n if (!symbol) return false;\n let known = standard.get(symbol.id);\n if (known === undefined) {\n const values = symbol.declarations.filter((d) => !typeOnly.has(d.kind));\n known =\n values.length > 0 &&\n values.every((d) => {\n const sf = d.resolve()?.getSourceFile();\n return sf !== undefined && program.isSourceFileDefaultLibrary(sf);\n });\n standard.set(symbol.id, known);\n }\n return known;\n };\n return fn({ program, checker, file, parseError, typeErrors, standardGlobal });\n } finally {\n snapshot.dispose();\n }\n}\n\n/** Run `fn` over a source file parsed from `text` alone (no program, no checker), released afterwards. */\nexport function withSourceFile<T>(text: string, fn: (sf: SourceFile) => T): T {\n const lease = compiler().createSourceFile(\"/eutaxy/reader/fragment.ts\", text);\n try {\n return fn(lease.sourceFile);\n } finally {\n lease.dispose();\n }\n}\n\n/** 1-based line of a node's first token. */\nexport function lineAt(sf: SourceFile, node: Node): number {\n return sf.getLineAndCharacterOfPosition(node.getStart(sf)).line + 1;\n}\n\n/** A node's text, leading trivia excluded. */\nexport function textOf(sf: SourceFile, node: Node): string {\n return sf.text.slice(node.getStart(sf), node.end);\n}\n\nexport function isExported(node: ModifiersBase): boolean {\n return (node.modifierFlags & ModifierFlags.Export) !== 0;\n}\n\nexport function isAsync(node: ModifiersBase): boolean {\n return (node.modifierFlags & ModifierFlags.Async) !== 0;\n}\n\nexport function isConst(list: VariableDeclarationList): boolean {\n return (list.flags & NodeFlags.Const) !== 0;\n}\n\n/**\n * The offset of the `(` opening a function's parameter list: the\n * declaration's identity, as the spec reader and the subset reader both\n * record it. Undefined for an arrow written without parentheses.\n */\nexport function openParen(sf: SourceFile, fn: FunctionLikeBase): number | undefined {\n const at = fn.parameters.pos - 1;\n return sf.text[at] === \"(\" ? at : undefined;\n}\n\n/** The name of a syntax kind, for messages. */\nexport function kindName(kind: SyntaxKind): string {\n return SyntaxKind[kind] ?? String(kind);\n}\n","/**\n * `restrictModule`: the module as an engine that takes only some of the\n * subset's types sees it.\n */\n\nimport {\n callees,\n children,\n type Expr,\n type SubsetFunction,\n type SubsetModule,\n type SubsetType,\n} from \"./tree.ts\";\n\n/** Whether an expression holds a node of the kinds named. */\nfunction hasNode(e: Expr, kinds: ReadonlySet<Expr[\"kind\"]>): boolean {\n if (kinds.has(e.kind)) return true;\n switch (e.kind) {\n case \"int\":\n case \"bool\":\n case \"string\":\n case \"null\":\n case \"var\":\n return false;\n case \"narrow\":\n case \"narrowTag\":\n return hasNode(e.body, kinds);\n case \"neg\":\n case \"not\":\n case \"isInteger\":\n case \"floor\":\n return hasNode(e.operand, kinds);\n case \"binary\":\n return hasNode(e.left, kinds) || hasNode(e.right, kinds);\n case \"cond\":\n return hasNode(e.test, kinds) || hasNode(e.ifTrue, kinds) || hasNode(e.ifFalse, kinds);\n case \"call\":\n return e.args.some((a) => hasNode(a, kinds));\n case \"field\":\n return hasNode(e.object, kinds);\n case \"record\":\n return e.fields.some((f) => hasNode(f.value, kinds));\n case \"let\":\n return hasNode(e.value, kinds) || hasNode(e.body, kinds);\n case \"list\":\n return e.items.some((x) => hasNode(x, kinds)) || (e.rest ? hasNode(e.rest, kinds) : false);\n case \"tail\":\n return hasNode(e.list, kinds);\n case \"headOr\":\n return hasNode(e.list, kinds) || hasNode(e.fallback, kinds);\n case \"iterate\":\n return hasNode(e.list, kinds) || hasNode(e.body, kinds);\n case \"fold\":\n return hasNode(e.list, kinds) || hasNode(e.init, kinds) || hasNode(e.body, kinds);\n }\n}\n\n/**\n * The module as an engine that takes only some of the subset's types sees\n * it: records with a field of a type it does not take are dropped, and so\n * are functions whose signature holds one, whose body uses what the\n * types bring (`null`, narrowing), or which call such a function; each is\n * reported outside with `reason`.\n */\nexport function restrictModule(\n module: SubsetModule,\n takes: (t: SubsetType) => boolean,\n reason: string,\n /** Expression kinds a function's body may not hold here: by default what nullable types and unions bring. */\n bodies: ReadonlySet<Expr[\"kind\"]> = new Set([\"null\", \"narrow\", \"narrowTag\"]),\n /** A body the engine refuses for what it computes, not its kinds or types (a division, say). */\n refused?: (body: Expr) => boolean,\n): SubsetModule {\n // A record with a field the engine does not take is out, and so is a union with such a member, and\n // so, in turn, is a record with a field of that union: to a fixed point.\n const badRecords = new Set<string>();\n for (const u of module.unions)\n if (!takes({ kind: \"union\", name: u.name })) badRecords.add(`union:${u.name}`);\n for (let changed = true; changed; ) {\n changed = false;\n for (const rec of module.records)\n if (\n !badRecords.has(rec.name) &&\n rec.fields.some((f) => !typeTaken(f.type, takes, badRecords))\n ) {\n badRecords.add(rec.name);\n changed = true;\n }\n for (const u of module.unions) {\n if (!badRecords.has(`union:${u.name}`) && u.members.some((m) => badRecords.has(m.record))) {\n badRecords.add(`union:${u.name}`);\n changed = true;\n }\n // A member of a dropped union stays a record of its own: every record has its own sort, so a\n // member of several unions does not go with one of them.\n }\n }\n const outside = new Map(module.outside.map((o) => [o.name, o]));\n const kept = new Map(module.functions.map((f) => [f.name, f]));\n const uses = (f: SubsetFunction) =>\n !f.params.every((p) => typeTaken(p.type, takes, badRecords)) ||\n !typeTaken(f.returns, takes, badRecords) ||\n annotations(f.body).some((t) => !typeTaken(t, takes, badRecords)) ||\n hasNode(f.body, bodies) ||\n refused?.(f.body) === true;\n for (const f of module.functions)\n if (uses(f)) {\n kept.delete(f.name);\n outside.set(f.name, { name: f.name, line: f.line, message: reason });\n }\n for (let changed = true; changed; ) {\n changed = false;\n for (const [name, f] of kept) {\n const bad = [...callees(f.body)].find((c) => outside.has(c));\n if (bad === undefined) continue;\n kept.delete(name);\n outside.set(name, {\n name,\n line: f.line,\n message: `calls ${bad}, which is outside the engine's subset: ${outside.get(bad)?.message}`,\n });\n changed = true;\n }\n }\n return {\n // A kept record names only the unions kept with it.\n records: module.records\n .filter((r) => !badRecords.has(r.name))\n .map((r) => {\n const unions = r.unions?.filter((u) => !badRecords.has(`union:${u}`));\n if (unions === r.unions) return r;\n const { unions: _, ...rest } = r;\n return unions && unions.length > 0 ? { ...rest, unions } : rest;\n }),\n unions: module.unions.filter((u) => !badRecords.has(`union:${u.name}`)),\n functions: module.functions.filter((f) => kept.has(f.name)),\n outside: [...outside.values()],\n };\n}\n\nfunction typeTaken(\n t: SubsetType,\n takes: (t: SubsetType) => boolean,\n badRecords: ReadonlySet<string>,\n): boolean {\n if (!takes(t)) return false;\n if (t.kind === \"record\") return !badRecords.has(t.name);\n if (t.kind === \"union\") return !badRecords.has(`union:${t.name}`);\n if (t.kind === \"nullable\") return typeTaken(t.inner, takes, badRecords);\n if (t.kind === \"list\") return typeTaken(t.element, takes, badRecords);\n return true;\n}\n\n/** The types a body's `const` annotations and its record literals' contexts name. */\nfunction annotations(e: Expr, out: SubsetType[] = []): SubsetType[] {\n if ((e.kind === \"let\" || e.kind === \"record\") && e.type) out.push(e.type);\n for (const c of children(e)) annotations(c, out);\n return out;\n}\n","/**\n * What a file may rebind, found in its syntax: a direct `eval`, a write\n * to a name (`isWritten`), and a direct assignment to a global of the\n * standard library or a property of one (`rebound`). What such an\n * assignment could reach another way is `builtinsAssumption`.\n */\n\nimport {\n type AsExpression,\n type Identifier,\n type Node,\n type NonNullExpression,\n type ParenthesizedExpression,\n type SatisfiesExpression,\n type SourceFile,\n SyntaxKind,\n type TypeAssertion,\n} from \"typescript/ast\";\nimport * as is from \"typescript/ast/is\";\nimport type { Checker } from \"typescript/sync\";\nimport { lineAt, textOf } from \"./compiler.ts\";\n\n/** The line of the first direct `eval` in the file: a mention that is not a property of something else. */\nexport function directEval(sf: SourceFile): number | undefined {\n let line: number | undefined;\n const visit = (node: Node): void => {\n if (line !== undefined) return;\n if (is.isIdentifier(node) && node.text === \"eval\") {\n const parent = node.parent;\n const property =\n (is.isPropertyAccessExpression(parent) && parent.name === node) ||\n (is.isPropertyAssignment(parent) && parent.name === node);\n if (!property) {\n line = lineAt(sf, node);\n return;\n }\n }\n node.forEachChild(visit);\n };\n visit(sf);\n return line;\n}\n\n/** An expression TypeScript lets wrap another without changing what it names: parentheses and assertions. */\ntype Wrapper =\n | ParenthesizedExpression\n | NonNullExpression\n | AsExpression\n | SatisfiesExpression\n | TypeAssertion;\n\nfunction isWrapper(n: Node): n is Wrapper {\n return (\n is.isParenthesizedExpression(n) ||\n is.isNonNullExpression(n) ||\n is.isAsExpression(n) ||\n is.isSatisfiesExpression(n) ||\n is.isTypeAssertion(n)\n );\n}\n\n/** Whether a node is written to: assigned, updated, or bound by a destructuring or a `for` head. */\nexport function isWritten(node: Node): boolean {\n let n: Node = node;\n for (;;) {\n const p: Node = n.parent;\n if (!p) return false;\n if (isWrapper(p) && p.expression === n) {\n n = p;\n continue;\n }\n if (is.isBinaryExpression(p)) {\n const k = p.operatorToken.kind;\n if (p.left === n && k >= SyntaxKind.FirstAssignment && k <= SyntaxKind.LastAssignment)\n return true;\n return false;\n }\n if (is.isPrefixUnaryExpression(p) || is.isPostfixUnaryExpression(p))\n return p.operator === SyntaxKind.PlusPlusToken || p.operator === SyntaxKind.MinusMinusToken;\n if (is.isForInStatement(p) || is.isForOfStatement(p)) return p.initializer === n;\n // Inside a destructuring target, the whole pattern is what gets assigned.\n if (is.isArrayLiteralExpression(p) || is.isSpreadElement(p) || is.isSpreadAssignment(p)) {\n n = p;\n continue;\n }\n if (is.isPropertyAssignment(p) && p.initializer === n) {\n n = p.parent;\n continue;\n }\n if (is.isShorthandPropertyAssignment(p) && p.name === n) {\n n = p.parent;\n continue;\n }\n if (is.isObjectLiteralExpression(p)) {\n n = p;\n continue;\n }\n return false;\n }\n}\n\n/** What every PROVEN rests on besides the engine's model: the reader's assumption about the built-ins. */\nexport const builtinsAssumption =\n \"the built-ins the subset reads (Math, Number and the array methods) are the standard ones: a direct assignment to a global of the standard library or to a property of one, or through globalThis, self or window, in a read file is refused, but one made another way (Object.defineProperty, through an alias) or elsewhere (a polyfill, another module) is not seen\";\n\n/** Names a file reaches the globals through that the library the reads compile against does not declare. */\nconst globalObjects = new Set([\"globalThis\", \"self\", \"window\", \"global\"]);\n\n/**\n * The first direct assignment (or `delete`) in a file whose target is a\n * global of the compiler's standard library or a property of one, at any\n * depth (`Math.floor = …`, `Number[\"isInteger\"] = …`, `Array.prototype.map\n * = …`, `Math = …`), or anything under `globalThis`, `self`, `window` or\n * `global`, with its line; inside a function or not. The chain's root is\n * resolved by the compiler, so a local's `prototype` field is the local's.\n * What reaches a built-in another way (`Object.defineProperty`, an alias)\n * is not seen: `builtinsAssumption` says so.\n */\nexport function rebound(\n sf: SourceFile,\n checker: Checker,\n standardGlobal: (id: Identifier) => boolean,\n): { line: number; target: string } | undefined {\n let found: { line: number; target: string } | undefined;\n // `window` and its kin, by name, unless the name is a parameter or a local of some function here.\n const globalObject = (r: Identifier): boolean => {\n if (!globalObjects.has(r.text)) return false;\n const decl = checker.getSymbolAtLocation(r)?.valueDeclaration?.resolve();\n if (!decl) return true;\n if (decl.kind === SyntaxKind.Parameter) return false;\n return !(is.isVariableDeclaration(decl) && decl.parent.parent.parent !== decl.getSourceFile());\n };\n // The node a `delete` would take: the target with the wrappers around it.\n const outermost = (node: Node): Node => {\n let out: Node = node;\n for (let p: Node = out.parent; p && isWrapper(p) && p.expression === out; p = p.parent) out = p;\n return out;\n };\n const root = (node: Node): Node => {\n let n: Node = node;\n while (is.isPropertyAccessExpression(n) || is.isElementAccessExpression(n) || isWrapper(n))\n n = n.expression;\n return n;\n };\n const builtin = (node: Node): boolean => {\n const r = root(node);\n return is.isIdentifier(r) && (globalObject(r) || standardGlobal(r));\n };\n const visit = (node: Node): void => {\n if (found) return;\n if (\n (is.isPropertyAccessExpression(node) ||\n is.isElementAccessExpression(node) ||\n is.isIdentifier(node)) &&\n (isWritten(node) || is.isDeleteExpression(outermost(node).parent)) &&\n builtin(node)\n ) {\n found = { line: lineAt(sf, node), target: textOf(sf, node) };\n return;\n }\n node.forEachChild(visit);\n };\n visit(sf);\n return found;\n}\n","/**\n * The subset's typing: `typeOf` types an expression in a scope, against\n * the records, unions and callee signatures of a `TypeContext`; `fits` is\n * the subset's assignability (a member where its union is, `null` or the\n * inner type where a nullable is).\n */\n\nimport {\n describe,\n type Expr,\n type Field,\n isMember,\n type Param,\n type RecordType,\n type SubsetType,\n type UnionType,\n} from \"./tree.ts\";\n\n/** A union's members among the records known, in the order they were read. */\nexport function membersIn(union: string, ctx: TypeContext): RecordType[] {\n return [...ctx.records.values()].filter((rec) => isMember(rec, union));\n}\n\nconst sameType = (a: SubsetType, b: SubsetType): boolean => JSON.stringify(a) === JSON.stringify(b);\n\n/**\n * Whether a value of one type may stand where another is expected: the\n * same type; a member record where its union is; `null`, or the inner\n * type, where a nullable is.\n */\nexport function fits(actual: SubsetType, expected: SubsetType, ctx: TypeContext): boolean {\n if (sameType(actual, expected)) return true;\n // The element of `[]` is no value at all, so it stands for any; a list fits where its elements do.\n if (actual.kind === \"nothing\") return true;\n if (actual.kind === \"list\" && expected.kind === \"list\")\n return fits(actual.element, expected.element, ctx);\n if (expected.kind === \"union\")\n return actual.kind === \"record\" && isMember(ctx.records.get(actual.name), expected.name);\n if (expected.kind === \"nullable\")\n return (\n actual.kind === \"null\" ||\n (actual.kind === \"nullable\"\n ? fits(actual.inner, expected.inner, ctx)\n : fits(actual, expected.inner, ctx))\n );\n return false;\n}\n\n/** The type two branches share, or undefined when they share none. */\nfunction join(a: SubsetType, b: SubsetType, ctx: TypeContext): SubsetType | undefined {\n if (fits(a, b, ctx)) return b;\n if (fits(b, a, ctx)) return a;\n if (a.kind === \"list\" && b.kind === \"list\") {\n const element = join(a.element, b.element, ctx);\n return element && { kind: \"list\", element };\n }\n if (a.kind === \"record\" && b.kind === \"record\") {\n // Two members of one union join to it; members of several unions in common join to none,\n // since nothing says which (an expected type, where one is given, decides instead).\n const ub = ctx.records.get(b.name)?.unions ?? [];\n const common = (ctx.records.get(a.name)?.unions ?? []).filter((u) => ub.includes(u));\n if (common.length === 1) return { kind: \"union\", name: common[0] as string };\n }\n if (a.kind === \"nullable\" && b.kind === \"nullable\") {\n const inner = join(a.inner, b.inner, ctx);\n return inner && { kind: \"nullable\", inner };\n }\n if (a.kind === \"null\" && b.kind !== \"null\") return { kind: \"nullable\", inner: b };\n if (b.kind === \"null\" && a.kind !== \"null\") return { kind: \"nullable\", inner: a };\n if (a.kind === \"nullable\" && b.kind !== \"null\" && b.kind !== \"nullable\") {\n const inner = join(a.inner, b, ctx);\n return inner && { kind: \"nullable\", inner };\n }\n if (b.kind === \"nullable\" && a.kind !== \"null\" && a.kind !== \"nullable\") {\n const inner = join(a, b.inner, ctx);\n return inner && { kind: \"nullable\", inner };\n }\n return undefined;\n}\n\n/** Whether `===` between the two types is in the subset, and on records (references in JavaScript) it is not. */\nfunction comparable(l: SubsetType, r: SubsetType): boolean {\n const base = (t: SubsetType): SubsetType => (t.kind === \"nullable\" ? t.inner : t);\n if (l.kind === \"null\" && r.kind === \"null\") return false;\n if (l.kind === \"null\") return r.kind === \"nullable\";\n if (r.kind === \"null\") return l.kind === \"nullable\";\n return sameType(base(l), base(r)) && !isReference(base(l));\n}\n\nconst isReference = (t: SubsetType): boolean =>\n t.kind === \"record\" || t.kind === \"union\" || t.kind === \"list\";\n\n/**\n * The element type of a list expression's type. An operation on an empty\n * array no type is given for (`[].length`, `[].slice(1)`) is refused: an\n * engine could only guess the element type, and such code has a plain\n * value to write instead; `const xs: T[] = []` gives one.\n */\nexport function elementOf(\n t: SubsetType,\n what: string,\n fail: (message: string) => never,\n): SubsetType {\n if (t.kind !== \"list\") fail(`${what} on a ${describe(t)}, not a list`);\n if (holdsNothing(t))\n fail(`${what} on an empty array of no declared type (annotate it: const xs: T[] = [])`);\n return t.element;\n}\n\n/** Whether a type holds the element type of an empty array literal anywhere in it (`[[]]` does). */\nfunction holdsNothing(t: SubsetType): boolean {\n if (t.kind === \"nothing\") return true;\n if (t.kind === \"list\") return holdsNothing(t.element);\n if (t.kind === \"nullable\") return holdsNothing(t.inner);\n return false;\n}\n\n/** The scope inside an iteration's callback: the item an element, the index an integer. */\nexport function iterateScope(\n e: Extract<Expr, { kind: \"iterate\" }>,\n list: Expr,\n scope: ReadonlyMap<string, SubsetType>,\n ctx: TypeContext,\n fail: (message: string) => never,\n): Map<string, SubsetType> {\n const inner = new Map(scope);\n inner.set(e.item, elementOf(typeOf(list, scope, ctx, fail), e.op, fail));\n if (e.index !== undefined) inner.set(e.index, { kind: \"int\" });\n return inner;\n}\n\n/**\n * The scope inside a fold's callback and the accumulator's type: the\n * initial value's, widened once to the body's when the body's holds it.\n * A callback that takes the accumulator apart as a list needs the initial\n * value typed (`xs.reduce((acc, x) => [x, ...acc], [])` does not\n * type-check in TypeScript either).\n */\nfunction foldScope(\n e: Extract<Expr, { kind: \"fold\" }>,\n list: Expr,\n init: Expr,\n scope: ReadonlyMap<string, SubsetType>,\n ctx: TypeContext,\n fail: (message: string) => never,\n): { scope: Map<string, SubsetType>; acc: SubsetType } {\n const item = elementOf(typeOf(list, scope, ctx, fail), \"reduce\", fail);\n const at = (acc: SubsetType) => new Map([...scope, [e.acc, acc], [e.item, item]]);\n const start = typeOf(init, scope, ctx, fail);\n const body = typeOf(e.body, at(start), ctx, fail);\n if (fits(body, start, ctx)) return { scope: at(start), acc: start };\n if (fits(start, body, ctx) && fits(typeOf(e.body, at(body), ctx, fail), body, ctx))\n return { scope: at(body), acc: body };\n fail(`reduce's callback makes a ${describe(body)} from an accumulator of ${describe(start)}`);\n}\n\n/** A function's parameters and return type, for typing calls. */\nexport interface CalleeSignature {\n readonly params: readonly Param[];\n readonly returns: SubsetType;\n}\n\n/** What typing an expression needs to know about its module. */\nexport interface TypeContext {\n readonly records: ReadonlyMap<string, RecordType>;\n /** The unions read so far, each naming its tag; a live list while a module is being read. */\n readonly unions: readonly UnionType[];\n readonly signatures: ReadonlyMap<string, CalleeSignature>;\n}\n\n/** The type of an expression in a scope; records are matched by their fields' names. */\nexport function typeOf(\n e: Expr,\n scope: ReadonlyMap<string, SubsetType>,\n ctx: TypeContext,\n fail: (message: string) => never,\n /**\n * The type the context declares for `e` (a return type, a const's\n * annotation, a parameter): it decides a conditional whose branches are\n * members of several unions in common, where they alone join to none.\n */\n expected?: SubsetType,\n): SubsetType {\n switch (e.kind) {\n case \"int\":\n return { kind: \"int\" };\n case \"bool\":\n return { kind: \"bool\" };\n case \"string\":\n return { kind: \"string\" };\n case \"null\":\n return { kind: \"null\" };\n case \"var\": {\n const t = scope.get(e.name);\n if (!t) fail(`${e.name} is not in scope`);\n return t;\n }\n case \"narrow\": {\n const t = scope.get(e.name);\n if (!t) fail(`${e.name} is not in scope`);\n if (t.kind !== \"nullable\")\n fail(`${e.name} is narrowed but is a ${describe(t)}, not a nullable`);\n return typeOf(e.body, new Map([...scope, [e.name, t.inner]]), ctx, fail, expected);\n }\n case \"narrowTag\": {\n const t = scope.get(e.name);\n if (!t) fail(`${e.name} is not in scope`);\n if (t.kind !== \"union\")\n fail(`${e.name} is narrowed by a tag but is a ${describe(t)}, not a union`);\n if (!isMember(ctx.records.get(e.member), t.name))\n fail(`${e.member} is not a member of ${t.name}`);\n return typeOf(\n e.body,\n new Map([...scope, [e.name, { kind: \"record\", name: e.member }]]),\n ctx,\n fail,\n expected,\n );\n }\n case \"binary\": {\n const l = typeOf(e.left, scope, ctx, fail);\n const r = typeOf(e.right, scope, ctx, fail);\n // `+` joins two strings; every other arithmetic or ordering operator is on integers only\n // (ordering strings compares UTF-16 code units in JavaScript and characters in Lean: not the same).\n if (e.op === \"+\" && l.kind === \"string\" && r.kind === \"string\") return { kind: \"string\" };\n const arithmetic = [\"+\", \"-\", \"*\", \"/\", \"<\", \"<=\", \">\", \">=\"].includes(e.op);\n if (arithmetic && (l.kind !== \"int\" || r.kind !== \"int\"))\n fail(\n `${e.op} on a ${l.kind} and a ${r.kind} (the subset has it on integers${e.op === \"+\" ? \", and + on two strings\" : \"\"})`,\n );\n if ((e.op === \"&&\" || e.op === \"||\") && (l.kind !== \"bool\" || r.kind !== \"bool\"))\n fail(`${e.op} on a ${l.kind} and a ${r.kind} (the subset has it on booleans)`);\n if (e.op === \"===\" || e.op === \"!==\") {\n // Against null, any nullable; otherwise records and unions are references in JavaScript.\n const againstNull = l.kind === \"null\" || r.kind === \"null\";\n const base = (t: SubsetType): SubsetType => (t.kind === \"nullable\" ? t.inner : t);\n if (!againstNull && (isReference(base(l)) || isReference(base(r))))\n fail(\n `${e.op} on records compares references in JavaScript; compare their fields instead`,\n );\n if (!comparable(l, r)) fail(`${e.op} between a ${describe(l)} and a ${describe(r)}`);\n }\n return [\"+\", \"-\", \"*\", \"/\"].includes(e.op) ? { kind: \"int\" } : { kind: \"bool\" };\n }\n case \"neg\": {\n const t = typeOf(e.operand, scope, ctx, fail);\n if (t.kind !== \"int\") fail(`unary minus on a ${t.kind}`);\n return { kind: \"int\" };\n }\n case \"not\": {\n const t = typeOf(e.operand, scope, ctx, fail);\n if (t.kind !== \"bool\") fail(`! on a ${t.kind}`);\n return { kind: \"bool\" };\n }\n case \"isInteger\": {\n const t = typeOf(e.operand, scope, ctx, fail);\n if (t.kind !== \"int\") fail(`Number.isInteger on a ${t.kind}`);\n return { kind: \"bool\" };\n }\n case \"floor\": {\n const t = typeOf(e.operand, scope, ctx, fail);\n if (t.kind !== \"int\") fail(`Math.floor on a ${t.kind}`);\n return { kind: \"int\" };\n }\n case \"cond\": {\n const test = typeOf(e.test, scope, ctx, fail);\n if (test.kind !== \"bool\")\n fail(\n `a condition that is a ${describe(test)} (truthiness is not in the subset; compare it)`,\n );\n const a = typeOf(e.ifTrue, scope, ctx, fail, expected);\n const b = typeOf(e.ifFalse, scope, ctx, fail, expected);\n const joined = join(a, b, ctx);\n if (joined) return joined;\n if (expected && fits(a, expected, ctx) && fits(b, expected, ctx)) return expected;\n return fail(\n `the branches of a conditional have different types (${describe(a)} and ${describe(b)})`,\n );\n }\n case \"let\": {\n const inferred = typeOf(e.value, scope, ctx, fail, e.type);\n if (e.type && !fits(inferred, e.type, ctx))\n fail(`const ${e.name} is annotated ${describe(e.type)} but holds a ${describe(inferred)}`);\n if (!e.type && holdsNothing(inferred))\n fail(\n `const ${e.name} holds an empty array of no declared type (annotate it: const ${e.name}: T[] = [])`,\n );\n return typeOf(e.body, new Map([...scope, [e.name, e.type ?? inferred]]), ctx, fail, expected);\n }\n case \"call\": {\n const sig = ctx.signatures.get(e.callee);\n if (!sig) fail(`the signature of ${e.callee} is not known`);\n if (sig.params.length !== e.args.length)\n fail(`${e.callee} takes ${sig.params.length} argument(s), called with ${e.args.length}`);\n e.args.forEach((a, i) => {\n const want = sig.params[i]?.type as SubsetType;\n const got = typeOf(a, scope, ctx, fail, want);\n if (!fits(got, want, ctx))\n fail(\n `argument ${i + 1} of ${e.callee} is a ${describe(got)}, not the ${describe(want)} it takes`,\n );\n });\n return sig.returns;\n }\n case \"field\": {\n const o = typeOf(e.object, scope, ctx, fail);\n if (o.kind === \"list\") {\n if (e.field !== \"length\") fail(`${e.field} read from a list (the subset has length)`);\n elementOf(o, \"length\", fail);\n return { kind: \"int\" };\n }\n if (o.kind === \"nullable\")\n fail(\n `field ${e.field} read from a ${describe(o)}: compare it with null first, which narrows it`,\n );\n if (o.kind === \"union\") {\n // Only a field every member has, with one type: the tag, typically. Narrowing by the tag is not in the subset yet.\n const members = membersIn(o.name, ctx);\n const types = members.map((rec) => rec.fields.find((x) => x.name === e.field)?.type);\n if (types.some((t) => t === undefined))\n fail(\n `field ${e.field} is not on every member of ${o.name} (test the tag first, which narrows it)`,\n );\n const first = types[0] as SubsetType;\n if (!types.every((t) => sameType(t as SubsetType, first)))\n fail(`field ${e.field} has different types across the members of ${o.name}`);\n return first;\n }\n if (o.kind !== \"record\") fail(`field ${e.field} read from a ${describe(o)}`);\n const f = ctx.records.get(o.name)?.fields.find((x) => x.name === e.field);\n if (!f) fail(`${o.name} has no field ${e.field}`);\n return f.type;\n }\n case \"record\": {\n // The record types whose fields are exactly these names, then those whose field types the values fit.\n const names = e.fields\n .map((f) => f.name)\n .sort()\n .join(\",\");\n // The context's type, when the compiler gave one, narrows the candidates: the record itself, or a union's members.\n const context = e.type;\n const candidates =\n context?.kind === \"record\"\n ? [...ctx.records.values()].filter((rec) => rec.name === context.name)\n : context?.kind === \"union\"\n ? membersIn(context.name, ctx)\n : [...ctx.records.values()];\n const byNames = candidates.filter(\n (rec) =>\n rec.fields\n .map((f) => f.name)\n .sort()\n .join(\",\") === names,\n );\n if (byNames.length === 0)\n fail(`a record literal with fields ${names} matches no declared record type`);\n const types = new Map(e.fields.map((f) => [f.name, typeOf(f.value, scope, ctx, fail)]));\n const fitting = byNames.filter((rec) =>\n rec.fields.every((f) => fits(types.get(f.name) as SubsetType, f.type, ctx)),\n );\n if (fitting.length === 0) {\n const rec = byNames[0] as RecordType;\n const off = rec.fields.find(\n (f) => !fits(types.get(f.name) as SubsetType, f.type, ctx),\n ) as Field;\n fail(\n `field ${off.name} of a ${rec.name} literal holds a ${describe(types.get(off.name) as SubsetType)}, not a ${describe(off.type)}`,\n );\n }\n // Among a union's members, the literal's tag tells them apart.\n const literalOf = (name: string): string | boolean | undefined => {\n const v = e.fields.find((f) => f.name === name)?.value;\n return v?.kind === \"string\" || v?.kind === \"bool\" ? v.value : undefined;\n };\n const tagged = fitting.filter((rec) =>\n rec.fields.every((f) => f.literal === undefined || literalOf(f.name) === f.literal),\n );\n const chosen = tagged.length > 0 ? tagged : fitting;\n if (chosen.length > 1)\n fail(\n `a record literal with fields ${names} matches ${chosen.map((r) => r.name).join(\" and \")} alike`,\n );\n return { kind: \"record\", name: (chosen[0] as RecordType).name };\n }\n case \"list\": {\n let element: SubsetType = { kind: \"nothing\" };\n const add = (t: SubsetType) => {\n const joined = join(element, t, ctx);\n if (!joined) fail(`an array literal of a ${describe(element)} and a ${describe(t)}`);\n element = joined;\n };\n for (const item of e.items) add(typeOf(item, scope, ctx, fail));\n if (e.rest) add(elementOf(typeOf(e.rest, scope, ctx, fail), \"a spread\", fail));\n return { kind: \"list\", element };\n }\n case \"tail\": {\n const t = typeOf(e.list, scope, ctx, fail);\n elementOf(t, \"slice\", fail);\n return t;\n }\n case \"headOr\": {\n const element = elementOf(typeOf(e.list, scope, ctx, fail), \"[0]\", fail);\n // `??` replaces null as well as the missing head: on a list of a nullable type it is not headD.\n if (element.kind === \"nullable\" || element.kind === \"null\")\n fail(\"xs[0] ?? on a list of a nullable type (?? replaces a null element too)\");\n const fallback = typeOf(e.fallback, scope, ctx, fail);\n const joined = join(element, fallback, ctx);\n if (!joined) fail(`?? between a ${describe(element)} and a ${describe(fallback)}`);\n return joined;\n }\n case \"iterate\": {\n const body = typeOf(e.body, iterateScope(e, e.list, scope, ctx, fail), ctx, fail);\n if (e.op === \"map\") return { kind: \"list\", element: body };\n if (e.op === \"flatMap\")\n return { kind: \"list\", element: elementOf(body, \"flatMap's callback result\", fail) };\n if (body.kind !== \"bool\")\n fail(`${e.op}'s callback returns a ${describe(body)}, not a boolean`);\n return { kind: \"bool\" };\n }\n case \"fold\":\n return foldScope(e, e.list, e.init, scope, ctx, fail).acc;\n }\n}\n","/**\n * A file's functions as declared: its top-level functions and which of\n * them may run something else (`fileFunctions`), a function's header and\n * body read against it (`head`, `declaration`), and why a range of a file\n * is not read: an error the compiler reports in it, or a directive that\n * hides one (`notCompiled`).\n */\n\nimport {\n type ArrowFunction,\n type Expression,\n type FunctionDeclaration,\n type FunctionExpression,\n forEachLeadingCommentRange,\n forEachTrailingCommentRange,\n type Identifier,\n type Node,\n type SourceFile,\n} from \"typescript/ast\";\nimport * as is from \"typescript/ast/is\";\nimport type { Checker } from \"typescript/sync\";\nimport { type CompilerError, isAsync, isConst, lineAt, openParen } from \"./compiler.ts\";\nimport type { ExprReader } from \"./expressions.ts\";\nimport { directEval, isWritten, rebound } from \"./rebinding.ts\";\nimport {\n describe,\n type OutsideFunction,\n type Param,\n type SubsetFunction,\n type SubsetType,\n} from \"./tree.ts\";\nimport type { SubsetTypes } from \"./types.ts\";\nimport { fits } from \"./typing.ts\";\n\n/**\n * The first `@ts-ignore` or `@ts-expect-error` directive in a range of a\n * file, with its position: a comment shaped as the compiler reads one (the\n * directive opens a `//` comment, or the last line of a block comment),\n * found as the compiler finds comments, leading or trailing a node's\n * text, so the words in prose or in a string are not one. A comment\n * before a closing token alone (`/* … *\\/ }`) is not seen; what it could\n * hide is on that token's line.\n */\nfunction directiveIn(\n sf: SourceFile,\n start: number,\n end: number,\n): { text: string; pos: number } | undefined {\n const text = sf.text;\n const singleLine = /^\\/\\/\\/?\\s*@ts-(ignore|expect-error)/;\n const lastLine = /^(?:\\/|\\*)*\\s*@ts-(ignore|expect-error)/;\n let found: { text: string; pos: number } | undefined;\n const check = (pos: number, commentEnd: number): void => {\n if (found || pos < start || commentEnd > end) return;\n const comment = text.slice(pos, commentEnd);\n // The compiler trims the block comment's last line before looking (`trimStringStart`).\n const m = comment.startsWith(\"//\")\n ? singleLine.exec(comment)\n : lastLine.exec(comment.slice(comment.lastIndexOf(\"\\n\") + 1).trimStart());\n if (m) found = { text: `@ts-${m[1]}`, pos };\n };\n const visit = (node: Node): void => {\n if (found || node.end < start || node.pos > end) return;\n forEachLeadingCommentRange(text, node.pos, check);\n forEachTrailingCommentRange(text, node.end, check);\n node.forEachChild(visit);\n };\n visit(sf);\n return found;\n}\n\n/**\n * The line of a `@ts-nocheck` directive at the top of a file, which turns\n * the compiler's checks off for all of it: as the compiler reads it, a\n * `//` comment opening with it, the last of it and `@ts-check` deciding.\n */\nfunction noCheckDirective(sf: SourceFile): number | undefined {\n const text = sf.text;\n const from = text.startsWith(\"#!\") ? Math.max(0, text.indexOf(\"\\n\")) : 0;\n let line: number | undefined;\n forEachLeadingCommentRange(text, from, (pos, end) => {\n const m = /^\\/\\/\\/?\\s*@ts-(check|nocheck)\\b/.exec(text.slice(pos, end));\n if (m) line = m[1] === \"nocheck\" ? sf.getLineAndCharacterOfPosition(pos).line + 1 : undefined;\n });\n return line;\n}\n\n/** A declaration's text, and the statement's leading comments, where a directive reaches its first line. */\nexport interface DeclaredRange {\n readonly start: number;\n readonly end: number;\n readonly lead?: { readonly start: number; readonly end: number };\n}\n\n/**\n * Why a range of a file is not read: the first error the compiler reports\n * inside it, or a `@ts-ignore` or `@ts-expect-error` directive in it or\n * in the leading comments (where a directive reaches the first line),\n * which hides one from the reader. Undefined when the range is clean.\n */\nexport function notCompiled(\n sf: SourceFile,\n typeErrors: (path: string) => readonly CompilerError[],\n { start, end, lead }: DeclaredRange,\n): { message: string; line: number } | undefined {\n const error = typeErrors(sf.fileName).find((e) => e.pos < end && e.end > start);\n if (error)\n return { message: `the compiler reports an error: ${error.message}`, line: error.line };\n const silenced =\n (lead ? directiveIn(sf, lead.start, lead.end) : undefined) ?? directiveIn(sf, start, end);\n if (silenced)\n return {\n message: `a ${silenced.text} comment, which hides a compiler error from the reader`,\n line: sf.getLineAndCharacterOfPosition(silenced.pos).line + 1,\n };\n return undefined;\n}\n\n/**\n * Where a declared function's errors are looked for: its own declaration\n * (in a `const` list, a sibling's error, or a directive in a sibling's\n * body, is the sibling's), and for directives the statement's leading\n * comments too, since a directive above the statement reaches its first\n * line, siblings included.\n */\nexport function rangeOf(d: Declared): DeclaredRange {\n let declaration: Node = d.node;\n while (!is.isFunctionDeclaration(declaration) && !is.isVariableDeclaration(declaration))\n declaration = declaration.parent;\n const sf = d.statement.getSourceFile();\n return {\n start: declaration.pos,\n end: declaration.end,\n lead: { start: d.statement.pos, end: d.statement.getStart(sf) },\n };\n}\n\n/**\n * The declared functions the module assigns to anywhere, with the line\n * of the first assignment: what runs under such a name may not be its\n * declaration. A name is confirmed through the compiler, so a local of\n * the same name assigned in some block is not the function.\n */\nfunction assigned(\n sf: SourceFile,\n checker: Checker,\n declarations: ReadonlyMap<string, Declared>,\n): Map<string, number> {\n const out = new Map<string, number>();\n const symbolIds = new Map<string, number | undefined>();\n const idOf = (name: string): number | undefined => {\n if (!symbolIds.has(name)) {\n const decl = declarations.get(name);\n symbolIds.set(name, decl ? checker.getSymbolAtLocation(decl.name)?.id : undefined);\n }\n return symbolIds.get(name);\n };\n const visit = (node: Node): void => {\n if (\n is.isIdentifier(node) &&\n declarations.has(node.text) &&\n !out.has(node.text) &&\n isWritten(node)\n ) {\n const id = idOf(node.text);\n // In `({ f } = …)` the name is the property's; the value it assigns is the binding's symbol.\n const parent = node.parent;\n const symbol =\n is.isShorthandPropertyAssignment(parent) && parent.name === node\n ? checker.getShorthandAssignmentValueSymbol(parent)\n : checker.getSymbolAtLocation(node);\n if (id !== undefined && symbol?.id === id) out.set(node.text, lineAt(sf, node));\n }\n node.forEachChild(visit);\n };\n visit(sf);\n return out;\n}\n\n/** A function as written: a declaration, or the arrow (or function expression) a module-level binding holds. */\ntype FunctionNode = FunctionDeclaration | ArrowFunction | FunctionExpression;\n\n/** A module-level function: its name, its node, and the statement declaring it (for its line). */\nexport interface Declared {\n readonly name: Identifier;\n readonly node: FunctionNode;\n readonly statement: Node;\n}\n\n/** A function's header read: its typed parameters and return type, with the body still to read. */\nexport interface Head {\n readonly name: string;\n readonly decl: FunctionNode;\n readonly params: readonly Param[];\n readonly returns: SubsetType;\n readonly line: number;\n readonly offset: number;\n}\n\n/** The parameter names of a function the subset can take at all: synchronous, no generator, plain parameters. */\nexport function shape(reader: ExprReader, decl: FunctionNode): string[] {\n if (isAsync(decl)) reader.fail(\"an async function (core functions are synchronous)\", decl);\n if (!is.isArrowFunction(decl) && decl.asteriskToken) reader.fail(\"a generator function\", decl);\n return decl.parameters.map((p) => {\n if (!is.isIdentifier(p.name)) reader.fail(\"a destructured parameter\", p);\n const pname = p.name.text;\n if (p.dotDotDotToken) reader.fail(\"a rest parameter\", p);\n // `this: T` annotates the receiver and is erased; it is no argument the function is called with.\n if (pname === \"this\") reader.fail(\"a this parameter (the receiver is not modelled)\", p);\n if (p.questionToken) reader.fail(`optional parameter ${pname}`, p);\n if (p.initializer) reader.fail(`a default value for ${pname}`, p);\n return pname;\n });\n}\n\n/** `export function name(params): Type {` or `export const name = (params): Type => …` read, the types through the compiler. */\nexport function head(reader: ExprReader, types: SubsetTypes, checker: Checker, d: Declared): Head {\n const sf = reader.sf;\n const decl = d.node;\n const name = d.name.text;\n const pnames = shape(reader, decl);\n if (decl.typeParameters) reader.fail(\"type parameters\", decl.typeParameters[0] ?? decl);\n const params: Param[] = decl.parameters.map((p, i) => {\n const pname = pnames[i] as string;\n if (!p.type) reader.fail(`parameter ${pname} without a type`, p);\n return {\n name: pname,\n type: types.of(checker.getTypeAtLocation(p.type), reader.refuseAt(p.type)),\n };\n });\n if (!decl.type)\n reader.fail(\n `${name} without a return type (the subset needs it to name the record returned)`,\n decl,\n );\n const returns = types.of(checker.getTypeAtLocation(decl.type), reader.refuseAt(decl.type));\n if (!decl.body) reader.fail(\"a function without a body\", decl);\n const offset = openParen(sf, decl);\n if (offset === undefined) reader.fail(\"a function without a parameter list\", decl);\n return { name, decl, params, returns, line: lineAt(sf, d.statement), offset };\n}\n\n/** The function, its body read and typed against its header. */\nexport function declaration(reader: ExprReader, h: Head): SubsetFunction {\n const body = h.decl.body as NonNullable<FunctionNode[\"body\"]>;\n const scope = new Map(h.params.map((p) => [p.name, p.type]));\n // An arrow's expression body is its one return. Null checks narrow the names they guard in the\n // branches they guard, before anything is typed.\n const statements = is.isBlock(body)\n ? reader.block(body.statements, scope, body)\n : reader.expression(body, scope);\n const read = reader.narrowed(statements, scope, body);\n // Typing the whole body here: a record literal of no declared type, a field read on an integer or\n // a body of another type than declared are all outside the subset, found now rather than by an engine.\n const actual = reader.typeOfExpr(read, scope, body, h.returns);\n if (!fits(actual, h.returns, reader.ctx))\n reader.fail(\n `${h.name} returns a ${describe(actual)} but declares ${describe(h.returns)}`,\n body,\n );\n return {\n name: h.name,\n params: h.params,\n returns: h.returns,\n body: read,\n line: h.line,\n offset: h.offset,\n };\n}\n\n/** A file's top-level functions, and the ones whose name may run something else, with why. */\nexport interface FileFunctions {\n readonly declarations: ReadonlyMap<string, Declared>;\n readonly overloaded: ReadonlySet<string>;\n readonly untrusted: ReadonlyMap<string, OutsideFunction>;\n /** What puts the whole file outside, functions and constants alike: eval, a built-in assigned to, or the compiler's checks turned off. */\n readonly tainted?: { readonly line: number; readonly message: string };\n}\n\n/**\n * A file's top-level functions: declarations, and the arrows module-level\n * consts hold. A binding that may be reassigned (let, var) or holds a\n * function expression is listed, for its callers' typing, and untrusted;\n * so is every function of a file mentioning eval directly or assigning to\n * a built-in, and a function the file assigns to.\n */\nexport function fileFunctions(\n sf: SourceFile,\n checker: Checker,\n standardGlobal: (id: Identifier) => boolean,\n): FileFunctions {\n const declarations = new Map<string, Declared>();\n const overloaded = new Set<string>();\n const untrusted = new Map<string, OutsideFunction>();\n const declare = (name: Identifier, node: FunctionNode, statement: Node): void => {\n if (declarations.has(name.text)) overloaded.add(name.text);\n else declarations.set(name.text, { name, node, statement });\n };\n for (const st of sf.statements) {\n if (is.isFunctionDeclaration(st)) {\n if (st.name) declare(st.name, st, st);\n continue;\n }\n if (!is.isVariableStatement(st)) continue;\n for (const d of st.declarationList.declarations) {\n if (!is.isIdentifier(d.name) || !d.initializer) continue;\n let init: Expression = d.initializer;\n while (is.isParenthesizedExpression(init)) init = init.expression;\n if (!is.isArrowFunction(init) && !is.isFunctionExpression(init)) continue;\n const name = d.name.text;\n declare(d.name, init, st);\n if (!isConst(st.declarationList))\n untrusted.set(name, {\n name,\n line: lineAt(sf, st),\n message: `${name} is declared with let or var, so what runs under its name may be another function`,\n });\n else if (is.isFunctionExpression(init))\n untrusted.set(name, {\n name,\n line: lineAt(sf, st),\n message: `${name} holds a function expression (write a function declaration or an arrow)`,\n });\n }\n }\n // A direct eval can rebind any declaration of the file without naming it, so any mention of `eval`\n // that is not a property of something else (`globalThis.eval` is indirect, and cannot) puts every\n // function outside: `eval(…)`, `(eval)(…)`, inside a template substitution alike. So does a\n // `@ts-nocheck` comment, which turns off the compiler's checks the reader relies on, and a direct\n // assignment to a built-in the subset reads as standard (`Math.floor = …`, `Array.prototype.map =\n // …`), wherever it is in the file: once it has run, the file's functions compute something else.\n // The engines state the assumption that nothing the reader does not see does this.\n const evalLine = directEval(sf);\n const noCheck = noCheckDirective(sf);\n const patched = rebound(sf, checker, standardGlobal);\n const tainted =\n evalLine !== undefined\n ? {\n line: evalLine,\n message: \"the module mentions eval directly, which can rebind any of its declarations\",\n }\n : noCheck !== undefined\n ? {\n line: noCheck,\n message:\n \"its file has a @ts-nocheck comment, which turns off the compiler's checks the reader relies on\",\n }\n : patched !== undefined\n ? {\n line: patched.line,\n message: `its file assigns to ${patched.target} (line ${patched.line}), so the built-ins its functions use may not be the standard ones`,\n }\n : undefined;\n if (tainted) for (const name of declarations.keys()) untrusted.set(name, { name, ...tainted });\n for (const [name, line] of assigned(sf, checker, declarations))\n if (!untrusted.has(name))\n untrusted.set(name, {\n name,\n line,\n message: `${name} is assigned in the module, so what runs under its name may not be its declaration`,\n });\n return { declarations, overloaded, untrusted, ...(tainted ? { tainted } : {}) };\n}\n","/**\n * Narrowing: what a test tells about a name where it holds or fails. A\n * comparison against `null` narrows a nullable name (`narrowsOf`), a test\n * of a union's tag narrows the name to that member (`tagNarrowsOf`), and\n * `insertNarrows` wraps the branches a test guards in `narrow` and\n * `narrowTag` nodes, so typing and the engines see the narrowed name.\n */\n\nimport type { Expr, RecordType, SubsetType } from \"./tree.ts\";\nimport { elementOf, iterateScope, membersIn, type TypeContext, typeOf } from \"./typing.ts\";\n\n/**\n * The names a test, holding or failing, shows to be non-null: `x !== null`\n * holding, `x === null` failing, through `!`, `&&` (holding) and `||`\n * (failing).\n */\nexport function narrowsOf(test: Expr, holds: boolean): string[] {\n // A narrowing already inserted around an operand (the right side of `&&`) hides nothing.\n if (test.kind === \"narrow\" || test.kind === \"narrowTag\") return narrowsOf(test.body, holds);\n const isNull = (e: Expr) => e.kind === \"null\";\n if (test.kind === \"binary\" && (test.op === \"===\" || test.op === \"!==\")) {\n const other = isNull(test.right) ? test.left : isNull(test.left) ? test.right : undefined;\n if (other?.kind !== \"var\") return [];\n return (test.op === \"!==\") === holds ? [other.name] : [];\n }\n if (test.kind === \"not\") return narrowsOf(test.operand, !holds);\n if (test.kind === \"binary\" && test.op === \"&&\" && holds)\n return [...narrowsOf(test.left, true), ...narrowsOf(test.right, true)];\n if (test.kind === \"binary\" && test.op === \"||\" && !holds)\n return [...narrowsOf(test.left, false), ...narrowsOf(test.right, false)];\n return [];\n}\n\n/**\n * The field that tells a union's members apart, as the union names it: the\n * one the types read chose (`UnionType.tag`), which the engines encode by.\n * Re-deriving it from the member records could pick another field where two\n * discriminate, and the reader would then refuse the test the engines take.\n */\nexport function tagOf(union: string, ctx: TypeContext): string | undefined {\n return ctx.unions.find((u) => u.name === union)?.tag;\n}\n\n/**\n * The names a test, holding or failing, shows to be one member of their\n * union, with that member: `x.tag === \"a\"` holding (or `!==` failing)\n * names the member tagged `\"a\"`; failing, the other member when the\n * union has two; `x.ok` alone is the test of a boolean tag; through `!`,\n * `&&` (holding) and `||` (failing) as null checks are.\n */\nexport function tagNarrowsOf(\n test: Expr,\n holds: boolean,\n scope: ReadonlyMap<string, SubsetType>,\n ctx: TypeContext,\n): { name: string; member: string }[] {\n // The union a `x.tag` read is the tag of, with its members by tag value.\n const tagged = (e: Expr): { name: string; members: readonly RecordType[] } | undefined => {\n if (e.kind !== \"field\" || e.object.kind !== \"var\") return undefined;\n const t = scope.get(e.object.name);\n if (t?.kind !== \"union\" || tagOf(t.name, ctx) !== e.field) return undefined;\n return {\n name: e.object.name,\n members: membersIn(t.name, ctx),\n };\n };\n const byTag = (\n read: { name: string; members: readonly RecordType[] },\n tag: string,\n value: string | boolean,\n isIt: boolean,\n ): { name: string; member: string }[] => {\n const same = read.members.filter(\n (m) => m.fields.find((f) => f.name === tag)?.literal === value,\n );\n const chosen = isIt ? same : read.members.filter((m) => !same.includes(m));\n return chosen.length === 1 ? [{ name: read.name, member: (chosen[0] as RecordType).name }] : [];\n };\n if (test.kind === \"narrow\" || test.kind === \"narrowTag\")\n return tagNarrowsOf(test.body, holds, scope, ctx);\n if (test.kind === \"binary\" && (test.op === \"===\" || test.op === \"!==\")) {\n const literal = (e: Expr) => (e.kind === \"string\" || e.kind === \"bool\" ? e.value : undefined);\n const [field, value] =\n literal(test.right) !== undefined\n ? [test.left, literal(test.right)]\n : [test.right, literal(test.left)];\n if (value === undefined || field.kind !== \"field\") return [];\n const read = tagged(field);\n if (!read) return [];\n return byTag(read, field.field, value, (test.op === \"===\") === holds);\n }\n if (test.kind === \"field\") {\n const read = tagged(test);\n return read ? byTag(read, test.field, holds, true) : [];\n }\n if (test.kind === \"not\") return tagNarrowsOf(test.operand, !holds, scope, ctx);\n if (test.kind === \"binary\" && test.op === \"&&\" && holds)\n return [\n ...tagNarrowsOf(test.left, true, scope, ctx),\n ...tagNarrowsOf(test.right, true, scope, ctx),\n ];\n if (test.kind === \"binary\" && test.op === \"||\" && !holds)\n return [\n ...tagNarrowsOf(test.left, false, scope, ctx),\n ...tagNarrowsOf(test.right, false, scope, ctx),\n ];\n return [];\n}\n\n/**\n * `narrow` and `narrowTag` nodes inserted where a test guards: in a\n * conditional's branches, and in the right operand of `&&` and `||`, for\n * each nullable name the test shows to be non-null there and each union\n * name it shows to be one member there.\n */\nexport function insertNarrows(\n e: Expr,\n scope: ReadonlyMap<string, SubsetType>,\n ctx: TypeContext,\n fail: (message: string) => never,\n): Expr {\n const go = (x: Expr, sc: ReadonlyMap<string, SubsetType>): Expr =>\n insertNarrows(x, sc, ctx, fail);\n // Where JavaScript tests truthiness (a condition, the operand of `!`), a nullable record or union\n // is falsy exactly when it is null, since an object is always truthy: `c` there is `c !== null`,\n // which then narrows as a null check does. A nullable number or string is no object, and stays.\n const probe = Symbol(\"untyped\");\n const condition = (x: Expr, sc: ReadonlyMap<string, SubsetType>): Expr => {\n if (x.kind === \"binary\" && (x.op === \"&&\" || x.op === \"||\"))\n return { ...x, left: condition(x.left, sc), right: condition(x.right, sc) };\n if (x.kind === \"not\") return { kind: \"not\", operand: condition(x.operand, sc) };\n let t: SubsetType;\n try {\n t = typeOf(x, sc, ctx, () => {\n throw probe;\n });\n } catch (err) {\n if (err === probe) return x;\n throw err;\n }\n if (t.kind === \"nullable\" && (t.inner.kind === \"record\" || t.inner.kind === \"union\"))\n return { kind: \"binary\", op: \"!==\", left: x, right: { kind: \"null\" } };\n return x;\n };\n const wrap = (\n body: Expr,\n test: Expr,\n holds: boolean,\n sc: ReadonlyMap<string, SubsetType>,\n ): Expr => {\n const inner = new Map(sc);\n let out = body;\n const nullable = [...new Set(narrowsOf(test, holds))].filter(\n (n) => sc.get(n)?.kind === \"nullable\",\n );\n for (const n of nullable) inner.set(n, (sc.get(n) as { inner: SubsetType }).inner);\n // Tag tests are read in the scope null checks leave: `x !== null && x.ok` narrows x twice.\n const tags: { name: string; member: string }[] = [];\n for (const t of tagNarrowsOf(test, holds, inner, ctx))\n if (!tags.some((x) => x.name === t.name)) {\n tags.push(t);\n inner.set(t.name, { kind: \"record\", name: t.member });\n }\n out = go(out, inner);\n for (const t of tags.reverse())\n out = { kind: \"narrowTag\", name: t.name, member: t.member, body: out };\n for (const n of nullable.reverse()) out = { kind: \"narrow\", name: n, body: out };\n return out;\n };\n switch (e.kind) {\n case \"int\":\n case \"bool\":\n case \"string\":\n case \"null\":\n case \"var\":\n return e;\n case \"not\":\n return { kind: \"not\", operand: go(condition(e.operand, scope), scope) };\n case \"neg\":\n case \"isInteger\":\n case \"floor\":\n return { kind: e.kind, operand: go(e.operand, scope) };\n case \"narrow\":\n case \"narrowTag\":\n return e;\n case \"binary\": {\n const left = go(e.left, scope);\n if (e.op === \"&&\")\n return { kind: \"binary\", op: e.op, left, right: wrap(e.right, left, true, scope) };\n if (e.op === \"||\")\n return { kind: \"binary\", op: e.op, left, right: wrap(e.right, left, false, scope) };\n return { kind: \"binary\", op: e.op, left, right: go(e.right, scope) };\n }\n case \"cond\": {\n const test = go(condition(e.test, scope), scope);\n return {\n kind: \"cond\",\n test,\n ifTrue: wrap(e.ifTrue, test, true, scope),\n ifFalse: wrap(e.ifFalse, test, false, scope),\n };\n }\n case \"call\":\n return { kind: \"call\", callee: e.callee, args: e.args.map((a) => go(a, scope)) };\n case \"field\":\n return { kind: \"field\", object: go(e.object, scope), field: e.field };\n case \"record\":\n return { ...e, fields: e.fields.map((f) => ({ name: f.name, value: go(f.value, scope) })) };\n case \"let\": {\n const value = go(e.value, scope);\n const inner = new Map(scope);\n inner.set(e.name, e.type ?? typeOf(value, scope, ctx, fail));\n return { ...e, value, body: go(e.body, inner) };\n }\n case \"list\":\n return {\n kind: \"list\",\n items: e.items.map((x) => go(x, scope)),\n ...(e.rest ? { rest: go(e.rest, scope) } : {}),\n };\n case \"tail\":\n return { kind: \"tail\", list: go(e.list, scope) };\n case \"headOr\":\n return { kind: \"headOr\", list: go(e.list, scope), fallback: go(e.fallback, scope) };\n case \"iterate\": {\n const list = go(e.list, scope);\n return { ...e, list, body: go(e.body, iterateScope(e, list, scope, ctx, fail)) };\n }\n case \"fold\": {\n const list = go(e.list, scope);\n const init = go(e.init, scope);\n // The callback's names before its body is typed: its null checks narrow first, as in map.\n const inner = new Map(scope);\n inner.set(e.acc, typeOf(init, scope, ctx, fail));\n inner.set(e.item, elementOf(typeOf(list, scope, ctx, fail), \"reduce\", fail));\n return { ...e, list, init, body: go(e.body, inner) };\n }\n }\n}\n","/**\n * Function bodies and spec arrows read from the compiler's syntax tree\n * into the subset's `Expr`: `const` bindings, `if` with early returns,\n * `return`, and expressions from arithmetic, comparisons, `&& || !`, the\n * conditional operator, record and array literals, field reads, list\n * methods and calls to the module's own functions. What a name stands\n * for comes from the scope (parameters and consts) and from `Names`: the\n * module's own functions when the text is the module, the spec file's\n * imports when it is an arrow. Anything else is `OutsideSubset` with the\n * construct named and its line.\n */\n\nimport {\n type ArrowFunction,\n type BinaryExpression,\n type Block,\n type CallExpression,\n type Expression,\n type Identifier,\n type Node,\n type ObjectLiteralExpression,\n type ReturnStatement,\n type SourceFile,\n type Statement,\n SyntaxKind,\n type TypeNode,\n} from \"typescript/ast\";\nimport * as is from \"typescript/ast/is\";\nimport { isAsync, isConst, kindName, lineAt, textOf } from \"./compiler.ts\";\nimport { insertNarrows, tagOf } from \"./narrowing.ts\";\nimport {\n type BinaryOp,\n type Expr,\n hasLoneSurrogate,\n OutsideSubset,\n type SubsetType,\n} from \"./tree.ts\";\nimport type { Refuse } from \"./types.ts\";\nimport { type TypeContext, typeOf } from \"./typing.ts\";\n\n/**\n * A call to a function the text cannot call by name (a generic one, or one\n * imported from another file) read as that function's body, bound to the\n * arguments: undefined when the callee is no such function, so the call is\n * refused as before. `readArgs` reads the arguments in the caller's scope,\n * a record literal argument typed as the parameter it is passed for when\n * that type is given; `fail` refuses at the call.\n */\nexport type Inline = (\n call: CallExpression,\n callee: Identifier,\n scope: Scope,\n readArgs: (types: readonly (SubsetType | undefined)[]) => Expr[],\n fail: (what: string) => never,\n) => Expr | undefined;\n\n/**\n * A name the text reads that is neither in scope nor a function: a\n * module-level `const` of the text's file or one it imports, read as its\n * initializer (a `const` holding a pure value is that value wherever it is\n * read). Undefined when the name is no such constant, so it is refused as\n * before; `fail` refuses at the name.\n */\nexport type Constant = (name: Identifier, fail: (what: string) => never) => Expr | undefined;\n\n/** What the bare names of the text being read stand for, outside any local scope. */\nexport interface Names {\n /** A function the subset may call under this name. */\n readonly callable: (name: string) => boolean;\n /** The module function a callable name stands for (a spec file's local name resolves to the module's). */\n readonly target: (name: string) => string;\n /** A function the text may name at all, in the subset or not: for messages. */\n readonly declared: (name: string) => boolean;\n /** Whether the text is a spec file's, whose names are its imports, never the module's. */\n readonly spec: boolean;\n /**\n * Whether an identifier is the global of its name (`Math`, `Number`):\n * for a module, the compiler resolves it to its standard library; for a\n * spec file's arrow, read from its text alone, every built-in it names\n * has been checked so by the spec reader, so any is.\n */\n readonly global: (id: Identifier) => boolean;\n}\n\n/** Where the types a body mentions come from: the compiler for the module, the module's own declared types for an arrow. */\nexport interface TypeSource {\n /** The subset type a `const` annotation names. */\n readonly annotation: (node: TypeNode, refuse: Refuse) => SubsetType;\n /** The type the context gives a record literal, when the compiler knows one the subset takes. */\n readonly contextual: (node: ObjectLiteralExpression) => SubsetType | undefined;\n}\n\nexport type Scope = ReadonlyMap<string, SubsetType>;\n\nconst binaryOps: Partial<Record<SyntaxKind, BinaryOp>> = {\n [SyntaxKind.PlusToken]: \"+\",\n [SyntaxKind.MinusToken]: \"-\",\n [SyntaxKind.AsteriskToken]: \"*\",\n [SyntaxKind.SlashToken]: \"/\",\n [SyntaxKind.LessThanToken]: \"<\",\n [SyntaxKind.LessThanEqualsToken]: \"<=\",\n [SyntaxKind.GreaterThanToken]: \">\",\n [SyntaxKind.GreaterThanEqualsToken]: \">=\",\n [SyntaxKind.EqualsEqualsEqualsToken]: \"===\",\n [SyntaxKind.ExclamationEqualsEqualsToken]: \"!==\",\n [SyntaxKind.AmpersandAmpersandToken]: \"&&\",\n [SyntaxKind.BarBarToken]: \"||\",\n};\n\nconst methods = new Set([\"slice\", \"map\", \"flatMap\", \"every\", \"some\", \"reduce\"]);\n\n/** The reader of one text: a function body, or an arrow of the spec file. */\nexport class ExprReader {\n readonly sf: SourceFile;\n readonly names: Names;\n readonly types: TypeSource;\n readonly ctx: TypeContext;\n /** The line a refusal reports for a node: the file's, or none for text whose position the caller knows. */\n private readonly lineOf: (node: Node) => number;\n private readonly inline: Inline | undefined;\n private readonly constant: Constant | undefined;\n /** Record literals typed by the call they are passed to, in place of the compiler's contextual type. */\n private readonly typedAs = new Map<Node, SubsetType>();\n\n constructor(\n sf: SourceFile,\n names: Names,\n types: TypeSource,\n ctx: TypeContext,\n lineOf: (node: Node) => number = (node) => lineAt(sf, node),\n inline?: Inline,\n constant?: Constant,\n ) {\n this.sf = sf;\n this.names = names;\n this.types = types;\n this.ctx = ctx;\n this.lineOf = lineOf;\n this.inline = inline;\n this.constant = constant;\n }\n\n /** Whether an identifier is the global of its name here: no scope or function shadows it, and the names confirm it. */\n private global(id: Identifier, scope: Scope): boolean {\n return !scope.has(id.text) && !this.names.declared(id.text) && this.names.global(id);\n }\n\n fail(what: string, at: Node): never {\n throw new OutsideSubset(what, this.lineOf(at));\n }\n\n /** `OutsideSubset` at a node, for a type read there. */\n refuseAt(at: Node): Refuse {\n return (what) => this.fail(what, at);\n }\n\n text(node: Node): string {\n return textOf(this.sf, node);\n }\n\n /** The expression with `narrow` nodes inserted where a null check guards a nullable name. */\n narrowed(e: Expr, scope: Scope, at: Node): Expr {\n return insertNarrows(e, scope, this.ctx, (m) => this.fail(m, at));\n }\n\n typeOfExpr(e: Expr, scope: Scope, at: Node, expected?: SubsetType): SubsetType {\n return typeOf(e, scope, this.ctx, (m) => this.fail(m, at), expected);\n }\n\n /**\n * A block's statements as one expression: `const` becomes `let`, `if (c)\n * return a; rest` a conditional, and the last statement must return:\n * every path ends in a `return`.\n */\n block(statements: readonly Statement[], scope: Scope, end: Node): Expr {\n return this.statements(statements, 0, scope, end);\n }\n\n private statements(statements: readonly Statement[], i: number, scope: Scope, end: Node): Expr {\n const s = statements[i];\n if (!s) this.fail(\"a path that does not return\", end);\n if (is.isEmptyStatement(s)) return this.statements(statements, i + 1, scope, end);\n if (is.isVariableStatement(s)) {\n const list = s.declarationList;\n if (!isConst(list)) this.fail(\"a mutable binding (use const)\", s);\n const [decl, second] = list.declarations;\n if (!decl || second) this.fail(\"several bindings in one const\", s);\n if (!is.isIdentifier(decl.name)) this.fail(\"a destructured const\", decl.name);\n const name = decl.name.text;\n // A const shadows a module function throughout its block, from before its own line (the temporal\n // dead zone): a call above it would throw where the reader would see the function. Refused outright.\n if (this.names.declared(name))\n this.fail(`const ${name} shadows the module's function ${name} in its block`, decl.name);\n if (scope.has(name))\n this.fail(`const ${name} redeclares a name already bound here`, decl.name);\n const annotated = decl.type\n ? this.types.annotation(decl.type, this.refuseAt(decl.type))\n : undefined;\n if (!decl.initializer) this.fail(`const ${name} without a value`, decl);\n const value = this.expression(decl.initializer, scope);\n // While reading, the scope carries names; types come from `typeOf` once null checks have narrowed\n // the tree, so an initializer under a guard is typed as the guard allows. The annotation is the\n // binding's type (a null initializer is then a nullable, not null); `typeOf` checks it fits.\n const inner = new Map(scope);\n inner.set(name, annotated ?? { kind: \"null\" });\n const body = this.statements(statements, i + 1, inner, end);\n return { kind: \"let\", name, value, body, ...(annotated ? { type: annotated } : {}) };\n }\n if (is.isIfStatement(s)) {\n const test = this.expression(s.expression, scope);\n const then = this.branch(s.thenStatement, scope);\n if (s.elseStatement) {\n const otherwise = this.branch(s.elseStatement, scope);\n const after = statements[i + 1];\n if (after) this.fail(\"statements after an if/else that both return\", after);\n return { kind: \"cond\", test, ifTrue: then, ifFalse: otherwise };\n }\n return {\n kind: \"cond\",\n test,\n ifTrue: then,\n ifFalse: this.statements(statements, i + 1, scope, end),\n };\n }\n if (is.isReturnStatement(s)) {\n const after = statements[i + 1];\n // `return` then a line break: JavaScript inserts a semicolon and returns undefined.\n if (!s.expression && after) {\n const gap = this.sf.text.slice(\n s.getStart(this.sf) + \"return\".length,\n after.getStart(this.sf),\n );\n if (/[\\n\\r\\u2028\\u2029]/.test(gap))\n this.fail(\n \"a line break after return (JavaScript inserts a semicolon and returns undefined)\",\n s,\n );\n }\n const value = this.returned(s, scope);\n if (after) this.fail(\"statements after a return\", after);\n return value;\n }\n if (\n is.isForStatement(s) ||\n is.isForOfStatement(s) ||\n is.isForInStatement(s) ||\n is.isWhileStatement(s) ||\n is.isDoStatement(s)\n )\n this.fail(\"a loop\", s);\n if (is.isThrowStatement(s)) this.fail(\"throw\", s);\n if (is.isSwitchStatement(s)) this.fail(\"switch\", s);\n if (is.isTryStatement(s)) this.fail(\"try\", s);\n if (is.isFunctionDeclaration(s)) this.fail(\"a nested function\", s);\n this.fail(`statement starting with ${this.text(s).split(/\\s/)[0] ?? kindName(s.kind)}`, s);\n }\n\n /** An `if` branch: `return e;` or `{ ...statements ending in return }`. */\n private branch(s: Statement, scope: Scope): Expr {\n if (is.isBlock(s)) return this.block(s.statements, scope, s);\n if (is.isReturnStatement(s)) return this.returned(s, scope);\n this.fail(\"an if branch that does not return\", s);\n }\n\n /** `return e;`. A line break after `return` makes JavaScript return undefined: no value, refused. */\n private returned(s: ReturnStatement, scope: Scope): Expr {\n if (!s.expression) this.fail(\"a return without a value\", s);\n return this.expression(s.expression, scope);\n }\n\n expression(node: Expression, scope: Scope): Expr {\n if (is.isParenthesizedExpression(node)) return this.expression(node.expression, scope);\n if (is.isIdentifier(node)) return this.identifier(node, scope);\n if (is.isNumericLiteral(node)) {\n const raw = this.text(node);\n if (!/^[0-9](_?[0-9])*$/.test(raw))\n this.fail(`the numeric literal ${raw} (integers in decimal only)`, node);\n return { kind: \"int\", value: raw.replace(/_/g, \"\") };\n }\n if (is.isBigIntLiteral(node)) this.fail(`the bigint literal ${this.text(node)}`, node);\n if (is.isStringLiteral(node)) {\n if (hasLoneSurrogate(node.text))\n this.fail(\"a string literal with a lone surrogate, which Lean's strings cannot hold\", node);\n return { kind: \"string\", value: node.text };\n }\n if (is.isNoSubstitutionTemplateLiteral(node) || is.isTemplateExpression(node))\n this.fail(\"a template literal\", node);\n if (is.isRegularExpressionLiteral(node)) this.fail(\"a regular expression\", node);\n if (node.kind === SyntaxKind.TrueKeyword) return { kind: \"bool\", value: true };\n if (node.kind === SyntaxKind.FalseKeyword) return { kind: \"bool\", value: false };\n if (node.kind === SyntaxKind.NullKeyword) return { kind: \"null\" };\n if (is.isPrefixUnaryExpression(node)) {\n if (node.operator === SyntaxKind.ExclamationToken)\n return { kind: \"not\", operand: this.expression(node.operand, scope) };\n if (node.operator === SyntaxKind.MinusToken) {\n const operand = this.expression(node.operand, scope);\n // A negated literal stays a literal with its sign flipped, so -(-1) is 1, never the text `--1`.\n return operand.kind === \"int\"\n ? {\n kind: \"int\",\n value: operand.value.startsWith(\"-\") ? operand.value.slice(1) : `-${operand.value}`,\n }\n : { kind: \"neg\", operand };\n }\n if (node.operator === SyntaxKind.PlusToken) this.fail(\"unary plus\", node);\n this.fail(`the ${this.text(node).slice(0, 2)} operator`, node);\n }\n if (is.isPostfixUnaryExpression(node))\n this.fail(`the ${this.text(node).slice(-2)} operator`, node);\n if (is.isTypeOfExpression(node)) this.fail(\"the typeof operator\", node);\n if (is.isVoidExpression(node)) this.fail(\"the void operator\", node);\n if (is.isAwaitExpression(node)) this.fail(\"the await operator\", node);\n if (is.isNewExpression(node)) this.fail(\"the new operator\", node);\n if (is.isDeleteExpression(node)) this.fail(\"the delete operator\", node);\n if (is.isBinaryExpression(node)) return this.binary(node, scope);\n if (is.isConditionalExpression(node))\n return {\n kind: \"cond\",\n test: this.expression(node.condition, scope),\n ifTrue: this.expression(node.whenTrue, scope),\n ifFalse: this.expression(node.whenFalse, scope),\n };\n if (is.isCallExpression(node)) return this.call(node, scope);\n if (is.isPropertyAccessExpression(node)) {\n if (node.questionDotToken) this.fail(\"optional chaining\", node);\n if (!is.isIdentifier(node.name)) this.fail(\"a private field\", node.name);\n return {\n kind: \"field\",\n object: this.expression(node.expression, scope),\n field: node.name.text,\n };\n }\n if (is.isElementAccessExpression(node)) {\n if (this.isHead(node))\n this.fail(\"xs[0] without ?? fallback (it is undefined on an empty list)\", node);\n this.fail(\"index access other than xs[0] ?? fallback\", node);\n }\n if (is.isObjectLiteralExpression(node)) return this.record(node, scope);\n if (is.isArrayLiteralExpression(node)) {\n const items: Expr[] = [];\n let rest: Expr | undefined;\n for (const item of node.elements) {\n if (rest) this.fail(\"a spread that is not last in an array literal\", item);\n if (is.isSpreadElement(item)) rest = this.expression(item.expression, scope);\n else if (is.isOmittedExpression(item)) this.fail(\"a hole in an array literal\", item);\n else items.push(this.expression(item, scope));\n }\n return { kind: \"list\", items, ...(rest ? { rest } : {}) };\n }\n if (is.isArrowFunction(node) || is.isFunctionExpression(node))\n this.fail(\"a function expression (the subset has callbacks of list methods only)\", node);\n if (is.isAsExpression(node)) this.fail(\"the as operator\", node);\n if (is.isSatisfiesExpression(node)) this.fail(\"the satisfies operator\", node);\n if (is.isNonNullExpression(node)) this.fail(\"the ! assertion\", node);\n if (is.isTypeAssertion(node)) this.fail(\"a type assertion\", node);\n if (node.kind === SyntaxKind.ThisKeyword) this.fail(\"this\", node);\n this.fail(`unexpected ${this.text(node) || kindName(node.kind)}`, node);\n }\n\n private identifier(node: Identifier, scope: Scope): Expr {\n const name = node.text;\n if (name === \"undefined\") this.fail(\"undefined (the subset has null)\", node);\n if (scope.has(name) || this.names.declared(name)) return { kind: \"var\", name };\n const constant = this.constant?.(node, (what) => this.fail(what, node));\n if (constant) return constant;\n // A built-in the compiler resolves to something other than its standard library: an import of the\n // name, say. (`Math.abs` reaches here too, as the global: its method is what the subset lacks.)\n if ((name === \"Math\" || name === \"Number\") && !this.names.global(node))\n this.fail(\n `${name}, which is not the standard ${name} here: a declaration of it other than the compiler's is in scope`,\n node,\n );\n this.fail(\n this.names.spec\n ? `${name}, which is neither a parameter, a const nor a function imported from the module beside the spec file`\n : `${name}, which is neither a parameter, a const nor a function of this module`,\n node,\n );\n }\n\n /** Whether an element access is `xs[0]`. */\n private isHead(node: Node): boolean {\n return (\n is.isElementAccessExpression(node) &&\n is.isNumericLiteral(node.argumentExpression) &&\n this.text(node.argumentExpression) === \"0\"\n );\n }\n\n private binary(node: BinaryExpression, scope: Scope): Expr {\n const kind = node.operatorToken.kind;\n const op = binaryOps[kind];\n if (op) {\n return {\n kind: \"binary\",\n op,\n left: this.expression(node.left, scope),\n right: this.expression(node.right, scope),\n };\n }\n if (kind === SyntaxKind.QuestionQuestionToken) {\n // `xs[0] ?? fallback` only: any other index may be past the end, which is undefined.\n if (is.isBinaryExpression(node.left) && node.left.operatorToken.kind === kind)\n this.fail(\"a chain of ??\", node);\n if (is.isElementAccessExpression(node.left) && !this.isHead(node.left))\n this.fail(\"index access other than xs[0] ?? fallback\", node.left);\n if (!is.isElementAccessExpression(node.left))\n this.fail(\n \"?? after anything but xs[0] (write xs[0] ?? fallback, parenthesized where it meets other operators)\",\n node,\n );\n if (node.left.questionDotToken) this.fail(\"optional chaining\", node.left);\n return {\n kind: \"headOr\",\n list: this.expression(node.left.expression, scope),\n fallback: this.expression(node.right, scope),\n };\n }\n if (kind >= SyntaxKind.FirstAssignment && kind <= SyntaxKind.LastAssignment)\n this.fail(\"an assignment\", node);\n if (kind === SyntaxKind.CommaToken) this.fail(\"the comma operator\", node);\n if (kind === SyntaxKind.InKeyword || kind === SyntaxKind.InstanceOfKeyword)\n this.fail(`the ${this.text(node.operatorToken)} operator`, node);\n this.fail(`the ${this.text(node.operatorToken)} operator`, node);\n }\n\n private call(node: CallExpression, scope: Scope): Expr {\n if (node.questionDotToken) this.fail(\"optional chaining\", node);\n let callee = node.expression;\n while (is.isParenthesizedExpression(callee)) callee = callee.expression;\n if (is.isPropertyAccessExpression(callee)) {\n if (callee.questionDotToken) this.fail(\"optional chaining\", callee);\n if (!is.isIdentifier(callee.name)) this.fail(\"a private method\", callee.name);\n const method = callee.name.text;\n const receiver = callee.expression;\n if (\n is.isIdentifier(receiver) &&\n receiver.text === \"Number\" &&\n method === \"isInteger\" &&\n this.global(receiver, scope)\n ) {\n const [arg, extra] = node.arguments;\n if (!arg || extra) this.fail(\"Number.isInteger takes one argument\", node);\n return { kind: \"isInteger\", operand: this.expression(arg, scope) };\n }\n if (\n is.isIdentifier(receiver) &&\n receiver.text === \"Math\" &&\n method === \"floor\" &&\n this.global(receiver, scope)\n ) {\n const [arg, extra] = node.arguments;\n if (!arg || extra) this.fail(\"Math.floor takes one argument\", node);\n return { kind: \"floor\", operand: this.expression(arg, scope) };\n }\n // The receiver first: `Math.abs` fails on `Math`, a name of nothing here, before its method.\n const list = this.expression(receiver, scope);\n if (!methods.has(method))\n this.fail(\n `the method ${method} (the subset has slice(1), map, flatMap, every, some and reduce)`,\n callee.name,\n );\n return this.method(node, list, method, scope);\n }\n if (!is.isIdentifier(callee)) this.fail(\"a call to a computed callee\", callee);\n const name = callee.text;\n // A binder or local named like a function shadows it: the call is to a number, which throws.\n if (scope.has(name))\n this.fail(`a call to ${name}, which names a value here, not the module's function`, callee);\n if (!this.names.callable(name) && this.inline) {\n const readArgs = (types: readonly (SubsetType | undefined)[]): Expr[] =>\n node.arguments.map((a, i) => {\n if (is.isSpreadElement(a)) this.fail(\"a spread argument\", a);\n const type = types[i];\n if (!type) return this.expression(a, scope);\n // The literals the argument evaluates to: itself, or a conditional's branches.\n const literals: Node[] = [];\n const collect = (e: Expression): void => {\n if (is.isParenthesizedExpression(e)) collect(e.expression);\n else if (is.isConditionalExpression(e)) {\n collect(e.whenTrue);\n collect(e.whenFalse);\n } else if (is.isObjectLiteralExpression(e)) literals.push(e);\n };\n collect(a);\n for (const l of literals) this.typedAs.set(l, type);\n try {\n return this.expression(a, scope);\n } finally {\n for (const l of literals) this.typedAs.delete(l);\n }\n });\n const inlined = this.inline(node, callee, scope, readArgs, (what) => this.fail(what, node));\n if (inlined) return inlined;\n }\n if (!this.names.declared(name)) this.identifier(callee, scope); // names nothing here: its message\n if (!this.names.callable(name))\n this.fail(`a call to ${name}, which is outside the subset`, callee);\n return {\n kind: \"call\",\n callee: this.names.target(name),\n args: node.arguments.map((a) => {\n if (is.isSpreadElement(a)) this.fail(\"a spread argument\", a);\n return this.expression(a, scope);\n }),\n };\n }\n\n /** `(a, b) => body` or `a => body`, an expression body only; the names it binds go into scope. */\n private callback(\n node: Expression,\n scope: Scope,\n arity: number,\n what: string,\n ): { names: string[]; body: Expr } {\n if (!is.isArrowFunction(node)) this.fail(`${what} takes an arrow function`, node);\n const arrow: ArrowFunction = node;\n // An async callback returns a promise, truthy whatever the body computes.\n if (isAsync(arrow)) this.fail(`an async callback in ${what}`, arrow);\n const names: string[] = [];\n for (const p of arrow.parameters) {\n if (!is.isIdentifier(p.name)) this.fail(`a destructured parameter of ${what}'s callback`, p);\n if (p.type) this.fail(`a type annotation on ${what}'s parameter`, p.type);\n if (p.initializer) this.fail(`a default value on ${what}'s parameter`, p);\n if (p.dotDotDotToken) this.fail(`a rest parameter on ${what}'s callback`, p);\n names.push(p.name.text);\n }\n if (names.length === 0 || names.length > arity)\n this.fail(\n `${what} takes a callback of 1 to ${arity} parameter(s), given ${names.length}`,\n arrow,\n );\n for (const n of names)\n if (scope.has(n) || this.names.declared(n))\n this.fail(`${what}'s parameter ${n} shadows a name already bound here`, arrow);\n if (new Set(names).size !== names.length)\n this.fail(`${what}'s parameters repeat a name`, arrow);\n if (is.isBlock(arrow.body))\n this.fail(`a block body in ${what}'s callback (write an expression)`, arrow.body);\n const inner = new Map(scope);\n for (const n of names) inner.set(n, { kind: \"null\" });\n return { names, body: this.expression(arrow.body, inner) };\n }\n\n /** A method call on a list: slice(1), map, flatMap, every, some, reduce. */\n private method(node: CallExpression, list: Expr, name: string, scope: Scope): Expr {\n const args = node.arguments;\n if (name === \"slice\") {\n const [one, extra] = args;\n if (!one || extra || !is.isNumericLiteral(one) || this.text(one) !== \"1\")\n this.fail(\"slice with an argument other than 1\", one ?? node);\n return { kind: \"tail\", list };\n }\n if (name === \"reduce\") {\n const [cb, init, extra] = args;\n if (!cb || !init || extra) this.fail(\"reduce takes a callback and an initial value\", node);\n const { names, body } = this.callback(cb, scope, 2, \"reduce\");\n if (names.length !== 2) this.fail(\"reduce takes a callback of (accumulator, item)\", cb);\n return {\n kind: \"fold\",\n list,\n acc: names[0] as string,\n item: names[1] as string,\n body,\n init: this.expression(init, scope),\n };\n }\n const [cb, extra] = args;\n if (!cb || extra) this.fail(`${name} takes one callback`, node);\n const { names, body } = this.callback(cb, scope, 2, name);\n return {\n kind: \"iterate\",\n op: name as \"map\" | \"flatMap\" | \"every\" | \"some\",\n list,\n item: names[0] as string,\n ...(names[1] === undefined ? {} : { index: names[1] }),\n body,\n };\n }\n\n private record(node: ObjectLiteralExpression, scope: Scope): Expr {\n const fields: { name: string; value: Expr }[] = [];\n for (const p of node.properties) {\n if (is.isSpreadAssignment(p)) this.fail(\"spread in a record literal\", p);\n if (is.isShorthandPropertyAssignment(p)) {\n if (!is.isIdentifier(p.name))\n this.fail(`a key that is not a name: ${this.text(p.name)}`, p.name);\n const name = p.name.text;\n if (name === \"__proto__\")\n this.fail(\"a __proto__ key, which sets the prototype, not a field\", p);\n if (!scope.has(name)) this.fail(`shorthand ${name} names nothing in scope`, p);\n fields.push({ name, value: { kind: \"var\", name } });\n continue;\n }\n if (!is.isPropertyAssignment(p)) this.fail(`a method ${this.text(p).split(\"(\")[0] ?? \"\"}`, p);\n if (is.isComputedPropertyName(p.name)) this.fail(\"a computed key\", p.name);\n if (!is.isIdentifier(p.name))\n this.fail(`a key that is not a name: ${this.text(p.name)}`, p.name);\n if (p.name.text === \"__proto__\")\n this.fail(\"a __proto__ key, which sets the prototype, not a field\", p.name);\n fields.push({ name: p.name.text, value: this.expression(p.initializer, scope) });\n }\n const type = this.typedAs.get(node) ?? this.types.contextual(node);\n const literal = (fs: typeof fields): Expr => ({\n kind: \"record\",\n fields: fs,\n ...(type ? { type } : {}),\n });\n // A member of a union picked by a conditional tag (`{ type: c ? \"a\" : \"b\", at }`) is one literal\n // per branch: the conditional moves out, the other fields go into each as written. The fields\n // are pure, so evaluating the test first computes the same value.\n const tag = type?.kind === \"union\" ? tagOf(type.name, this.ctx) : undefined;\n const chosen = tag === undefined ? undefined : fields.find((f) => f.name === tag);\n if (chosen?.value.kind === \"cond\") {\n const split = (value: Expr): Expr =>\n value.kind === \"cond\"\n ? {\n kind: \"cond\",\n test: value.test,\n ifTrue: split(value.ifTrue),\n ifFalse: split(value.ifFalse),\n }\n : literal(fields.map((f) => (f === chosen ? { name: f.name, value } : f)));\n return split(chosen.value);\n }\n return literal(fields);\n }\n}\n\n/**\n * A `const` annotation inside a spec arrow, read from its syntax against\n * the module's declared types: no compiler stands behind an arrow's\n * text, so a name must be a record or union the module reads, and the\n * forms are the primitives, `null`, literals, unions of those and arrays.\n */\nexport function syntacticType(\n sf: SourceFile,\n node: TypeNode,\n records: ReadonlySet<string>,\n unions: ReadonlySet<string>,\n refuse: Refuse,\n): SubsetType {\n const go = (n: TypeNode): SubsetType => syntacticType(sf, n, records, unions, refuse);\n if (is.isParenthesizedTypeNode(node)) return go(node.type);\n if (is.isTypeOperatorNode(node) && node.operator === SyntaxKind.ReadonlyKeyword) {\n if (!is.isArrayTypeNode(node.type))\n return refuse(\"readonly before a type that is not an array\");\n return go(node.type);\n }\n if (is.isArrayTypeNode(node)) return { kind: \"list\", element: go(node.elementType) };\n if (node.kind === SyntaxKind.NumberKeyword) return { kind: \"int\" };\n if (node.kind === SyntaxKind.BooleanKeyword) return { kind: \"bool\" };\n if (node.kind === SyntaxKind.StringKeyword) return { kind: \"string\" };\n if (node.kind === SyntaxKind.UndefinedKeyword)\n return refuse(\"undefined in a type (the subset has null)\");\n if (is.isLiteralTypeNode(node)) {\n const lit = node.literal;\n if (lit.kind === SyntaxKind.NullKeyword) return { kind: \"null\" };\n if (lit.kind === SyntaxKind.TrueKeyword || lit.kind === SyntaxKind.FalseKeyword)\n return { kind: \"bool\" };\n if (is.isStringLiteral(lit)) return { kind: \"string\" };\n return refuse(`the literal type ${textOf(sf, node)}`);\n }\n if (is.isTypeReferenceNode(node)) {\n if (node.typeArguments)\n return refuse(`type ${textOf(sf, node)} (a generic type in an arrow's const)`);\n if (!is.isIdentifier(node.typeName)) return refuse(`type ${textOf(sf, node)}`);\n const name = node.typeName.text;\n if (records.has(name)) return { kind: \"record\", name };\n if (unions.has(name)) return { kind: \"union\", name };\n return refuse(\n `type ${name} (the subset has number, boolean, string, null, and the module's own record types and unions)`,\n );\n }\n if (is.isUnionTypeNode(node)) {\n const members = node.types.map(go);\n const nulls = members.filter((m) => m.kind === \"null\");\n const rest = members.filter((m) => m.kind !== \"null\");\n const first = rest[0];\n if (!first) return refuse(\"null alone is not a type the subset takes\");\n if (!rest.every((m) => JSON.stringify(m) === JSON.stringify(first)))\n return refuse(\"a union of several types (declare it as a type alias in the module)\");\n if (nulls.length === 0) return first;\n return first.kind === \"nullable\" ? first : { kind: \"nullable\", inner: first };\n }\n return refuse(`type ${textOf(sf, node)}`);\n}\n\n/**\n * The block body of an arrow read from a parsed fragment: the statements\n * between the braces, every path returning.\n */\nexport function blockOf(sf: SourceFile): Block | undefined {\n const [first, second] = sf.statements;\n return first && !second && is.isBlock(first) ? first : undefined;\n}\n","/**\n * Renaming: `renameVars` renames an expression's free names without\n * capture, moving the names it binds out of the way (`boundNames`,\n * `fresh`). A spec arrow's parameters become the binders', and an\n * inlined callee's names move away from its caller's.\n */\n\nimport type { Expr } from \"./tree.ts\";\n\n/** Every name an expression binds or refers to: its variables and its lets. */\nexport function boundNames(e: Expr, out = new Set<string>()): Set<string> {\n switch (e.kind) {\n case \"int\":\n case \"bool\":\n case \"string\":\n case \"null\":\n return out;\n case \"var\":\n out.add(e.name);\n return out;\n case \"narrow\":\n case \"narrowTag\":\n out.add(e.name);\n return boundNames(e.body, out);\n case \"neg\":\n case \"not\":\n case \"isInteger\":\n case \"floor\":\n return boundNames(e.operand, out);\n case \"binary\":\n boundNames(e.left, out);\n return boundNames(e.right, out);\n case \"cond\":\n boundNames(e.test, out);\n boundNames(e.ifTrue, out);\n return boundNames(e.ifFalse, out);\n case \"call\":\n for (const a of e.args) boundNames(a, out);\n return out;\n case \"field\":\n return boundNames(e.object, out);\n case \"record\":\n for (const f of e.fields) boundNames(f.value, out);\n return out;\n case \"let\":\n out.add(e.name);\n boundNames(e.value, out);\n return boundNames(e.body, out);\n case \"list\":\n for (const x of e.items) boundNames(x, out);\n return e.rest ? boundNames(e.rest, out) : out;\n case \"tail\":\n return boundNames(e.list, out);\n case \"headOr\":\n boundNames(e.list, out);\n return boundNames(e.fallback, out);\n case \"iterate\":\n out.add(e.item);\n if (e.index !== undefined) out.add(e.index);\n boundNames(e.list, out);\n return boundNames(e.body, out);\n case \"fold\":\n out.add(e.acc);\n out.add(e.item);\n boundNames(e.list, out);\n boundNames(e.init, out);\n return boundNames(e.body, out);\n }\n}\n\n/** A name not among `taken`: the name with underscores appended. */\nexport function fresh(name: string, taken: ReadonlySet<string>): string {\n let out = `${name}_`;\n while (taken.has(out)) out += \"_\";\n return out;\n}\n\n/**\n * The expression with its variables renamed (an arrow's own parameter\n * names to the binders'). A `let` whose name is a rename's target would\n * capture the renamed references in its body, so such a let is renamed to\n * a fresh name first; a let whose name is a rename's source shadows it.\n */\nexport function renameVars(\n e: Expr,\n names: ReadonlyMap<string, string>,\n taken: ReadonlySet<string> = new Set([...names.keys(), ...names.values(), ...boundNames(e)]),\n /** Names no binder in `e` may keep (the scope `e` is inlined into): such a binder moves to a fresh name. */\n avoid: ReadonlySet<string> = new Set(),\n): Expr {\n const go = (x: Expr): Expr => renameVars(x, names, taken, avoid);\n switch (e.kind) {\n case \"int\":\n case \"bool\":\n case \"string\":\n case \"null\":\n return e;\n case \"var\":\n return { kind: \"var\", name: names.get(e.name) ?? e.name };\n case \"narrow\":\n return { kind: \"narrow\", name: names.get(e.name) ?? e.name, body: go(e.body) };\n case \"narrowTag\":\n return { ...e, name: names.get(e.name) ?? e.name, body: go(e.body) };\n case \"neg\":\n case \"not\":\n case \"isInteger\":\n case \"floor\":\n return { kind: e.kind, operand: go(e.operand) };\n case \"binary\":\n return { kind: \"binary\", op: e.op, left: go(e.left), right: go(e.right) };\n case \"cond\":\n return { kind: \"cond\", test: go(e.test), ifTrue: go(e.ifTrue), ifFalse: go(e.ifFalse) };\n case \"call\":\n return { kind: \"call\", callee: e.callee, args: e.args.map(go) };\n case \"field\":\n return { kind: \"field\", object: go(e.object), field: e.field };\n case \"record\":\n return { ...e, fields: e.fields.map((f) => ({ name: f.name, value: go(f.value) })) };\n case \"let\": {\n // A let binds its own name; a binder of that name is shadowed inside, as in the source.\n const inner = new Map(names);\n inner.delete(e.name);\n let bound = e.name;\n const targets = new Set([...names.values(), ...avoid]);\n if (targets.has(e.name)) {\n // The let would capture a renamed reference: the let itself moves out of the way, to a name\n // nothing in the expression uses (another let may already be spelled with the underscore).\n bound = fresh(e.name, taken);\n inner.set(e.name, bound);\n }\n return {\n ...e,\n name: bound,\n value: go(e.value),\n body: renameVars(e.body, inner, new Set([...taken, bound]), avoid),\n };\n }\n case \"list\":\n return { kind: \"list\", items: e.items.map(go), ...(e.rest ? { rest: go(e.rest) } : {}) };\n case \"tail\":\n return { kind: \"tail\", list: go(e.list) };\n case \"headOr\":\n return { kind: \"headOr\", list: go(e.list), fallback: go(e.fallback) };\n case \"iterate\": {\n const own = [e.item, ...(e.index === undefined ? [] : [e.index])];\n const { inner, bound, scoped } = bindAll(own, names, taken, avoid);\n return {\n ...e,\n list: go(e.list),\n item: bound[0] as string,\n ...(e.index === undefined ? {} : { index: bound[1] as string }),\n body: renameVars(e.body, inner, scoped, avoid),\n };\n }\n case \"fold\": {\n const { inner, bound, scoped } = bindAll([e.acc, e.item], names, taken, avoid);\n return {\n ...e,\n list: go(e.list),\n init: go(e.init),\n acc: bound[0] as string,\n item: bound[1] as string,\n body: renameVars(e.body, inner, scoped, avoid),\n };\n }\n }\n}\n\n/**\n * The renames inside a callback that binds `own` names, as for a let:\n * each shadows a rename of its own name, and one that is a rename's target\n * moves to a fresh name so it captures nothing.\n */\nfunction bindAll(\n own: readonly string[],\n names: ReadonlyMap<string, string>,\n taken: ReadonlySet<string>,\n avoid: ReadonlySet<string>,\n): { inner: Map<string, string>; bound: string[]; scoped: Set<string> } {\n const inner = new Map(names);\n const targets = new Set([...names.values(), ...avoid]);\n const scoped = new Set(taken);\n const bound = own.map((n) => {\n inner.delete(n);\n if (!targets.has(n)) return n;\n const moved = fresh(n, scoped);\n scoped.add(moved);\n inner.set(n, moved);\n return moved;\n });\n return { inner, bound, scoped };\n}\n","/**\n * Inlining: a call to a function the module cannot name as its own (a\n * generic one, or one of another file) read as the callee's body bound\n * to the arguments, and a module-level constant read as its value.\n */\n\nimport type { Identifier, Node, SourceFile } from \"typescript/ast\";\nimport * as is from \"typescript/ast/is\";\nimport { type Checker, SymbolFlags, type Type } from \"typescript/sync\";\nimport { type CompilerError, isConst } from \"./compiler.ts\";\nimport {\n type DeclaredRange,\n type FileFunctions,\n fileFunctions,\n notCompiled,\n rangeOf,\n shape,\n} from \"./declarations.ts\";\nimport {\n type Constant,\n ExprReader,\n type Inline,\n type Names,\n type TypeSource,\n} from \"./expressions.ts\";\nimport { boundNames, fresh, renameVars } from \"./rename.ts\";\nimport { describe, type Expr, OutsideSubset, type SubsetType } from \"./tree.ts\";\nimport type { SubsetTypes } from \"./types.ts\";\nimport { fits, type TypeContext } from \"./typing.ts\";\n\n/** What inlining a module's calls needs from the read it belongs to. */\ninterface InlinerContext {\n readonly checker: Checker;\n readonly types: SubsetTypes;\n readonly typeSource: TypeSource;\n readonly ctx: TypeContext;\n /** The module being read, and its functions. */\n readonly module: SourceFile;\n readonly own: FileFunctions;\n readonly parseError: (path: string) => { line: number; message: string } | undefined;\n readonly typeErrors: (path: string) => readonly CompilerError[];\n /** Whether an identifier names the global of its name (`Math`): the compiler resolves it to its standard library. */\n readonly standardGlobal: (id: Identifier) => boolean;\n}\n\n/**\n * Bind the type parameters in `declared` so that it is `expected`, or a\n * member of `expected` when that is a union: a parameter binds to what it\n * meets, and two instantiations of one alias match argument by argument.\n * Returns the type matched (the union member, say), or undefined, with\n * `bound` unchanged by a member that did not match.\n */\nfunction match(declared: Type, expected: Type, bound: Map<number, Type>): Type | undefined {\n if (declared.isTypeParameter()) {\n const had = bound.get(declared.id);\n if (had && had.id !== expected.id) return undefined;\n bound.set(declared.id, expected);\n return expected;\n }\n const alias = declared.getAliasSymbol();\n const other = expected.getAliasSymbol();\n if (alias && other && alias.id === other.id) {\n const xs = declared.getAliasTypeArguments();\n const ys = expected.getAliasTypeArguments();\n if (xs.length !== ys.length) return undefined;\n const trial = new Map(bound);\n for (let i = 0; i < xs.length; i++)\n if (!match(xs[i] as Type, ys[i] as Type, trial)) return undefined;\n for (const [k, v] of trial) bound.set(k, v);\n return expected;\n }\n if (expected.isUnionType())\n for (const member of expected.getTypes()) {\n const trial = new Map(bound);\n if (match(declared, member, trial)) {\n for (const [k, v] of trial) bound.set(k, v);\n return member;\n }\n }\n return undefined;\n}\n\n/**\n * Calls to functions the module cannot name as its own, read inlined: a\n * generic function (of the module or not) at the call's instantiation,\n * and a function of another file, as the compiler resolves the import.\n * The callee's body is read in its own file under the parameter types the\n * call's resolved signature gives, its literals typed by the resolved\n * return type, its names moved away from the caller's, and bound by `let`\n * to the arguments in order: a pure function called by value computes\n * exactly that. The callee's own calls inline the same way, so the\n * helpers of its file come with it. A callee with no body here (a\n * declaration file), one its file may rebind, or one reached again while\n * it is being inlined (recursion) is outside the subset, with why.\n */\nexport function inliner(c: InlinerContext): { inline: Inline; constant: Constant } {\n const files = new Map<SourceFile, FileFunctions>([[c.module, c.own]]);\n const functionsOf = (file: SourceFile): FileFunctions => {\n let found = files.get(file);\n if (!found) {\n found = fileFunctions(file, c.checker, c.standardGlobal);\n files.set(file, found);\n }\n return found;\n };\n // Whether a declaration's text compiles, once per declaration however often it is read.\n const vetted = new Map<Node, { message: string; line: number } | undefined>();\n const vet = (\n file: SourceFile,\n key: Node,\n range: DeclaredRange,\n ): { message: string; line: number } | undefined => {\n if (!vetted.has(key)) vetted.set(key, notCompiled(file, c.typeErrors, range));\n return vetted.get(key);\n };\n const inlining: string[] = [];\n // The type parameters of the functions being read, bound to the types their calls give them,\n // innermost last: a generic function read inside another sees the outer one's as concrete types.\n const substitutions: Map<number, Type>[] = [];\n const concrete = (t: Type): Type => {\n const top = substitutions[substitutions.length - 1];\n return top && t.isTypeParameter() ? (top.get(t.id) ?? t) : t;\n };\n // `fail` is annotated so that the compiler narrows after a call to it.\n const inline: Inline = (call, callee, scope, readArgs, fail: (what: string) => never) => {\n // A call the compiler rejects (a name imported with `import type`, which does not exist when the\n // code runs; arguments that do not fit) is no call the reader may stand in for.\n const caller = call.getSourceFile();\n const start = call.getStart(caller);\n if (c.typeErrors(caller.fileName).some((e) => e.pos < call.end && e.end > start))\n fail(`the compiler reports an error on this call to ${callee.text}`);\n let symbol = c.checker.getSymbolAtLocation(callee);\n if (!symbol) return undefined;\n if (symbol.flags & SymbolFlags.Alias) symbol = c.checker.getAliasedSymbol(symbol);\n const decl = symbol.valueDeclaration?.resolve();\n if (!decl || !(is.isFunctionDeclaration(decl) || is.isVariableDeclaration(decl)))\n return undefined;\n const file = decl.getSourceFile();\n // The declaration's own name: a default export's symbol is named `default`.\n const name = decl.name && is.isIdentifier(decl.name) ? decl.name.text : symbol.name;\n const where = file === c.module ? name : `${name} (from ${file.fileName})`;\n if (file.isDeclarationFile)\n fail(`${where} has no body to read: it is declared in a declaration file`);\n const fns = functionsOf(file);\n const d = fns.declarations.get(name);\n // Only a top-level function of its file is read; anything else is refused by the usual message.\n if (!d || !decl.name || d.name.pos !== decl.name.pos) return undefined;\n if (c.parseError(file.fileName)) fail(`${where} is in a file the compiler cannot parse`);\n const untrusted = fns.untrusted.get(name);\n if (untrusted) fail(`${where} is outside the subset: ${untrusted.message}`);\n if (fns.overloaded.has(name)) fail(`${where} is declared more than once (overloads)`);\n const body = d.node.body;\n if (!body) fail(`${where} has no body to read`);\n // A callee the compiler reports an error in computes something its text does not say.\n const bad = vet(file, d.node, rangeOf(d));\n if (bad)\n fail(\n `${where} is outside the subset: ${bad.message} (line ${bad.line}${file === c.module ? \"\" : \" of its file\"})`,\n );\n const signature = c.checker.getResolvedSignature(call);\n if (c.checker.isUnknownSignature(signature)) fail(`the call to ${where} does not resolve`);\n const fileNames: Names = {\n callable: () => false,\n target: (n) => n,\n declared: (n) => fns.declarations.has(n),\n spec: false,\n global: c.standardGlobal,\n };\n const typeSource: TypeSource = {\n annotation: (node, refuse) => c.types.of(concrete(c.checker.getTypeAtLocation(node)), refuse),\n contextual: c.typeSource.contextual,\n };\n const reader = new ExprReader(file, fileNames, typeSource, c.ctx, undefined, inline, constant);\n const params = shape(reader, d.node);\n const symbols = signature.getParameters();\n if (symbols.length !== params.length || call.arguments.length !== params.length)\n fail(`${where} takes ${params.length} argument(s), called with ${call.arguments.length}`);\n // A generic callee is instantiated by where its value goes first: the compiler infers `E` in\n // `err({ type: \"locked\" })` from the argument alone, a record of its own, where the caller's\n // declared result names the error union the literal belongs to. What the context leaves open\n // is the compiler's instantiation.\n const bound = new Map<number, Type>();\n const declared = c.checker.getSignatureFromDeclaration(d.node);\n const generalReturn = c.checker.getReturnTypeOfSignature(declared);\n const context = d.node.typeParameters ? c.checker.getContextualType(call) : undefined;\n const matched = context ? match(generalReturn, concrete(context), bound) : undefined;\n const declaredParams = declared.getParameters();\n const generalParams = symbols.map((_, i) => {\n const own = declaredParams[i];\n return own ? c.checker.getTypeOfSymbol(own) : undefined;\n });\n const resolvedParams = symbols.map((p) => concrete(c.checker.getTypeOfSymbol(p)));\n const resolvedReturn = concrete(c.checker.getReturnTypeOfSignature(signature));\n // The callee's own type parameters, for its body: the context's first, the compiler's after.\n generalParams.forEach((g, i) => {\n if (g) match(g, resolvedParams[i] as Type, bound);\n });\n match(generalReturn, resolvedReturn, bound);\n const types = symbols.map((_, i) => {\n const g = generalParams[i];\n const type =\n g?.isTypeParameter() && bound.has(g.id)\n ? concrete(bound.get(g.id) as Type)\n : (resolvedParams[i] as Type);\n return c.types.of(type, (what) =>\n fail(`${where}, parameter ${params[i]} at this call: ${what}`),\n );\n });\n const returns = c.types.of(matched ?? resolvedReturn, (what) =>\n fail(`${where} returns, at this call, ${what}`),\n );\n const own = new Map([...bound].map(([k, v]) => [k, concrete(v)]));\n // The arguments in the caller's scope, before this callee is marked as being read: a nested call\n // to the same function is no recursion.\n const args = readArgs(types);\n const key = `${file.fileName}#${name}`;\n if (inlining.includes(key))\n fail(\n `${where} is recursive, which a function read at its calls cannot be (recursion is in the subset only as a module's own structural recursion)`,\n );\n inlining.push(key);\n substitutions.push(own);\n try {\n const inner = new Map(params.map((p, i) => [p, types[i] as SubsetType]));\n const readBody = (): Expr => {\n const read = returning(\n is.isBlock(body)\n ? reader.block(body.statements, inner, body)\n : reader.expression(body, inner),\n returns,\n );\n const actual = reader.typeOfExpr(reader.narrowed(read, inner, body), inner, body, returns);\n if (!fits(actual, returns, c.ctx))\n reader.fail(\n `returns a ${describe(actual)}, not the ${describe(returns)} called for`,\n body,\n );\n return read;\n };\n let read: Expr;\n try {\n read = readBody();\n } catch (err) {\n if (!(err instanceof OutsideSubset)) throw err;\n fail(\n `${where}, read at this call, is outside the subset: ${err.message} (line ${err.line} of its file)`,\n );\n }\n // Its parameters and its own names move away from every name the caller has here.\n const callerNames = new Set([...scope.keys(), ...args.flatMap((a) => [...boundNames(a)])]);\n // Every parameter name is reserved, used or not, so no fresh name repeats one.\n const taken = new Set([...callerNames, ...boundNames(read), ...params]);\n const renames = new Map<string, string>();\n for (const p of params) {\n const to = callerNames.has(p) ? fresh(p, taken) : p;\n taken.add(to);\n renames.set(p, to);\n }\n const renamed = renameVars(read, renames, taken, callerNames);\n return params.reduceRight<Expr>(\n (rest, p, i) => ({\n kind: \"let\",\n name: renames.get(p) as string,\n value: args[i] as Expr,\n body: rest,\n type: types[i] as SubsetType,\n }),\n renamed,\n );\n } finally {\n substitutions.pop();\n inlining.pop();\n }\n };\n // The constants being read, innermost last: one that reaches itself is refused.\n const reading: string[] = [];\n const constant: Constant = (name, fail: (what: string) => never) => {\n let symbol = c.checker.getSymbolAtLocation(name);\n if (!symbol) return undefined;\n const imported = (symbol.flags & SymbolFlags.Alias) !== 0;\n if (imported) symbol = c.checker.getAliasedSymbol(symbol);\n const decl = symbol.valueDeclaration?.resolve();\n if (!decl || !is.isVariableDeclaration(decl) || !is.isIdentifier(decl.name)) return undefined;\n const list = decl.parent;\n const statement = list.parent;\n const file = decl.getSourceFile();\n // A module-level `const` only: a `let` or `var` may be rebound, a local is not this name.\n if (!is.isVariableDeclarationList(list) || !is.isVariableStatement(statement)) return undefined;\n // A local the compiler resolves the name to, which the reader has not bound, is declared later in\n // its block: a const there throws when used before its line, a var reads undefined.\n if (statement.parent !== file)\n fail(`${name.text}, which is declared after this use in its block`);\n const where = file === c.module ? decl.name.text : `${decl.name.text} (from ${file.fileName})`;\n // A global (Math, say) is declared in the compiler's own declaration files: no constant here.\n if (file.isDeclarationFile && !imported) return undefined;\n if (file.isDeclarationFile)\n fail(`${where} has no value to read: it is declared in a declaration file`);\n if (!isConst(list)) fail(`${where} is a module-level let or var, which may be rebound`);\n // A name the compiler rejects here (used before its declaration, say) is not read.\n const at = name.getSourceFile();\n const start = name.getStart(at);\n if (c.typeErrors(at.fileName).some((e) => e.pos < name.end && e.end > start))\n fail(`the compiler reports an error on ${name.text} here`);\n if (c.parseError(file.fileName)) fail(`${where} is in a file the compiler cannot parse`);\n const init = decl.initializer;\n if (!init) fail(`${where} has no initializer`);\n if (is.isArrowFunction(init) || is.isFunctionExpression(init)) return undefined;\n // The declaration as a whole: a declared type the value does not fit is reported on the name.\n const bad = vet(file, decl, {\n start: decl.pos,\n end: decl.end,\n lead: { start: statement.pos, end: statement.getStart(file) },\n });\n if (bad)\n fail(\n `${where} is outside the subset: ${bad.message} (line ${bad.line}${file === c.module ? \"\" : \" of its file\"})`,\n );\n const key = `${file.fileName}#${decl.name.text}`;\n if (reading.includes(key)) fail(`${where} is defined in terms of itself`);\n const fns = functionsOf(file);\n // A constant of a file that may rebind a built-in, or whose checks are off, is no value to trust.\n if (fns.tainted) fail(`${where} is outside the subset: ${fns.tainted.message}`);\n const fileNames: Names = {\n callable: () => false,\n target: (n) => n,\n declared: (n) => fns.declarations.has(n),\n spec: false,\n global: c.standardGlobal,\n };\n const reader = new ExprReader(\n file,\n fileNames,\n c.typeSource,\n c.ctx,\n undefined,\n undefined,\n constant,\n );\n reading.push(key);\n try {\n const value = reader.expression(init, new Map());\n if (!isValue(value))\n reader.fail(\n `${decl.name.text} holds something other than a number, boolean or string built from literals, operators and other such constants`,\n init,\n );\n return value;\n } catch (err) {\n if (!(err instanceof OutsideSubset)) throw err;\n fail(\n `${where}, read where it is used, is outside the subset: ${err.message} (line ${err.line} of its file)`,\n );\n } finally {\n reading.pop();\n }\n };\n return { inline, constant };\n}\n\n/**\n * Whether an expression is a value a constant may hold: literals of the\n * primitive types and the operators on them, with no name, call or record.\n */\nfunction isValue(e: Expr): boolean {\n switch (e.kind) {\n case \"int\":\n case \"bool\":\n case \"string\":\n return true;\n case \"neg\":\n case \"not\":\n case \"isInteger\":\n case \"floor\":\n return isValue(e.operand);\n case \"binary\":\n return isValue(e.left) && isValue(e.right);\n case \"cond\":\n return isValue(e.test) && isValue(e.ifTrue) && isValue(e.ifFalse);\n default:\n return false;\n }\n}\n\n/**\n * The expression with the record literals it returns typed `t`, where\n * they have no type of their own: a function inlined at a call returns\n * its instantiated type, which a literal in a generic body cannot name.\n */\nfunction returning(e: Expr, t: SubsetType): Expr {\n const target = t.kind === \"nullable\" ? t.inner : t;\n if (target.kind !== \"record\" && target.kind !== \"union\") return e;\n switch (e.kind) {\n case \"record\":\n return e.type ? e : { ...e, type: target };\n case \"let\":\n case \"narrow\":\n case \"narrowTag\":\n return { ...e, body: returning(e.body, t) };\n case \"cond\":\n return { ...e, ifTrue: returning(e.ifTrue, t), ifFalse: returning(e.ifFalse, t) };\n default:\n return e;\n }\n}\n","/**\n * The compiler's types read two ways. `specTypeOf` reads a type into\n * `SpecType` as far as the spec surface describes it (primitives,\n * literals, records, unions, arrays), marking the rest `unknown` with its\n * text: binder domains for the simulator's rungs. `SubsetTypes` reads a\n * type into the subset's own types (integers, booleans, strings, records,\n * nullable types, tagged unions, lists), naming every record and union it\n * meets so the engines can declare them: a declared type by its name, an\n * instantiated generic or an inline object type as the compiler prints\n * it, a union member declared inline by its union and its tag. Both read\n * what the compiler resolved, so a type declared later in the file, in\n * another file, or through a generic alias reads as its structure.\n */\n\nimport type { SpecType } from \"@eutaxy/spec\";\nimport { SyntaxKind } from \"typescript/ast\";\nimport * as is from \"typescript/ast/is\";\nimport {\n type Checker,\n SymbolFlags,\n type Type,\n TypeFlags,\n TypeFormatFlags,\n type TypeReference,\n} from \"typescript/sync\";\nimport type { Field, RecordType, SubsetType, UnionType } from \"./tree.ts\";\n\n/** Levels of records and lists inside one another a type may hold before it is cut (a generic instantiating itself anew at each level never repeats). */\nconst maxDepth = 16;\n\n/**\n * Why an object type is not plain data, or undefined when it is: a class\n * (an instance is more than its fields: nominal, with private ones), or an\n * interface over a base the compiler could not resolve (it then shows the\n * interface's own fields alone) or over a class.\n */\nexport function notPlain(\n checker: Checker,\n type: Type,\n seen: Set<number> = new Set(),\n): string | undefined {\n const symbol = type.getSymbol();\n if (!symbol || seen.has(type.id)) return undefined;\n seen.add(type.id);\n if ((symbol.flags & SymbolFlags.Class) !== 0)\n return \"a class (an instance is more than a record of its fields)\";\n if ((symbol.flags & SymbolFlags.Interface) === 0) return undefined;\n for (const handle of symbol.declarations) {\n if (handle.kind !== SyntaxKind.InterfaceDeclaration) continue;\n const decl = handle.resolve();\n if (!decl || !is.isInterfaceDeclaration(decl)) continue;\n for (const clause of decl.heritageClauses ?? [])\n for (const base of clause.types) {\n const baseType = checker.getTypeAtLocation(base);\n if (baseType.isErrorType()) return `extends ${base.getText()}, which does not resolve`;\n // The whole ancestry: a class anywhere up makes the interface nominal.\n const why = notPlain(checker, baseType, seen);\n if (why !== undefined) return `extends ${base.getText()}: ${why}`;\n }\n }\n return undefined;\n}\n\n/** A type as the compiler prints it, in full. */\nexport function printType(checker: Checker, type: Type): string {\n return checker.typeToString(type, undefined, TypeFormatFlags.NoTruncation);\n}\n\n/**\n * The name a record or union goes by: its alias or interface name when\n * declared without type arguments, otherwise the type as the compiler\n * prints it (`Result<true, Locked>`, `{ readonly ok: boolean; }`).\n */\nexport function nameOfType(checker: Checker, type: Type): string {\n const alias = type.getAliasSymbol();\n if (alias)\n return type.getAliasTypeArguments().length === 0 ? alias.name : printType(checker, type);\n const symbol = type.getSymbol();\n if (\n symbol &&\n (symbol.flags & (SymbolFlags.Interface | SymbolFlags.Class)) !== 0 &&\n !(type.isTypeReference() && checker.getTypeArguments(type).length > 0)\n )\n return symbol.name;\n return printType(checker, type);\n}\n\n/** A union's members with `true | false` folded back into `boolean`, which the compiler keeps apart. */\nfunction foldBooleans(members: readonly Type[]): (Type | \"boolean\")[] {\n const isTrue = (t: Type) => t.isBooleanLiteralType() && t.value === true;\n const isFalse = (t: Type) => t.isBooleanLiteralType() && t.value === false;\n if (!members.some(isTrue) || !members.some(isFalse)) return [...members];\n const out: (Type | \"boolean\")[] = [];\n let folded = false;\n for (const m of members) {\n if (isTrue(m) || isFalse(m)) {\n if (!folded) out.push(\"boolean\");\n folded = true;\n } else out.push(m);\n }\n return out;\n}\n\n/** The members of a union as one type: flattened, deduplicated, one member alone. */\nexport function unionOf(members: readonly SpecType[]): SpecType {\n const flat = members.flatMap((m) => (m.kind === \"union\" ? m.members : [m]));\n const seen = new Set<string>();\n const unique = flat.filter((m) => {\n const key = JSON.stringify(m);\n if (seen.has(key)) return false;\n seen.add(key);\n return true;\n });\n return unique.length === 1 ? (unique[0] as SpecType) : { kind: \"union\", members: unique };\n}\n\n/** A type into `SpecType`; what the spec surface does not describe is `unknown` with the type's text. */\nexport function specTypeOf(\n checker: Checker,\n type: Type,\n seen: ReadonlySet<number> = new Set(),\n): SpecType {\n const unknown = (): SpecType => ({ kind: \"unknown\", text: printType(checker, type) });\n const flags = type.flags;\n if (type.isErrorType()) return unknown();\n if (flags & TypeFlags.Number) return { kind: \"number\" };\n if (flags & TypeFlags.String) return { kind: \"string\" };\n if (flags & TypeFlags.Boolean) return { kind: \"boolean\" };\n if (flags & TypeFlags.BigInt) return { kind: \"bigint\" };\n if (type.isStringLiteralType() || type.isNumberLiteralType() || type.isBooleanLiteralType())\n return { kind: \"literal\", value: type.value };\n if (flags & TypeFlags.Null) return { kind: \"null\" };\n if (flags & (TypeFlags.Undefined | TypeFlags.Void)) return { kind: \"undefined\" };\n if (type.isUnionType())\n return unionOf(\n foldBooleans(type.getTypes()).map((m) =>\n m === \"boolean\" ? { kind: \"boolean\" } : specTypeOf(checker, m, seen),\n ),\n );\n if (!type.isObjectType()) return unknown();\n // A type reaching itself through a field or an element: the cycle is cut with the type's name;\n // one that nests without repeating is cut at a depth.\n if (seen.has(type.id) || seen.size >= maxDepth) return unknown();\n const inner = new Set(seen).add(type.id);\n if (checker.isArrayType(type)) {\n const element = checker.getTypeArguments(type as TypeReference)[0];\n return element ? { kind: \"array\", element: specTypeOf(checker, element, inner) } : unknown();\n }\n if (\n type.isTupleType() ||\n type.getCallSignatures().length > 0 ||\n type.getConstructSignatures().length > 0 ||\n type.getIndexInfos().length > 0\n )\n return unknown();\n if (notPlain(checker, type) !== undefined) return unknown();\n const properties = type.getProperties();\n // An object with a method or an accessor is no record of plain data (a Map, a class instance), and\n // neither is one keyed by a symbol (the compiler names it `__@key@…`, which no string names).\n const computed = SymbolFlags.Method | SymbolFlags.GetAccessor | SymbolFlags.SetAccessor;\n if (properties.some((p) => (p.flags & computed) !== 0 || isSymbolKey(p.name))) return unknown();\n const fields = properties.map((p) => ({\n name: p.name,\n type: specTypeOf(checker, checker.getTypeOfSymbol(p), inner),\n }));\n return { kind: \"record\", name: nameOfType(checker, type), fields };\n}\n\n/** Whether a property's name is the compiler's spelling of a symbol key, which no string names. */\nconst isSymbolKey = (name: string): boolean => name.startsWith(\"__@\");\n\n/** Names a Lean structure declaration generates itself, which a field cannot take. */\nconst structureNames = new Set([\n \"mk\",\n \"rec\",\n \"recOn\",\n \"casesOn\",\n \"noConfusion\",\n \"noConfusionType\",\n \"injEq\",\n]);\n\n/** `OutsideSubset` at the type being read, by the reader that asked. */\nexport type Refuse = (what: string) => never;\n\n/**\n * The subset's types read from the compiler's, with every record and\n * union met along the way kept by name, in the order met, for the engines\n * to declare. One type is read once: a second meeting gives the same\n * record, and so does another compiler type of the same name and the\n * same fields (an inline type written twice). A type the subset does not\n * take is refused with the construct named, and a read that is refused\n * leaves nothing behind: whatever it registered on the way is taken back,\n * so no record belongs to a union that was never declared.\n */\nexport class SubsetTypes {\n readonly records = new Map<string, RecordType>();\n readonly unions: UnionType[] = [];\n private readonly checker: Checker;\n /** By the compiler's type id. */\n private readonly byId = new Map<number, SubsetType>();\n private readonly idOfName = new Map<string, number>();\n /** Types being read now, to refuse a type that holds itself. */\n private readonly reading = new Set<number>();\n\n constructor(checker: Checker) {\n this.checker = checker;\n }\n\n /** The subset type of a compiler type, or a refusal, after which nothing of the read remains. */\n of(type: Type, refuse: Refuse): SubsetType {\n const cached = this.byId.get(type.id);\n if (cached) return cached;\n if (this.reading.size > 0) return this.enter(type, refuse);\n // The outermost read of a type: all or nothing.\n const saved = {\n records: new Map(this.records),\n idOfName: new Map(this.idOfName),\n byId: new Map(this.byId),\n unions: this.unions.length,\n };\n try {\n return this.enter(type, refuse);\n } catch (err) {\n this.records.clear();\n for (const [k, v] of saved.records) this.records.set(k, v);\n this.idOfName.clear();\n for (const [k, v] of saved.idOfName) this.idOfName.set(k, v);\n this.byId.clear();\n for (const [k, v] of saved.byId) this.byId.set(k, v);\n this.unions.length = saved.unions;\n throw err;\n }\n }\n\n /** A type read under the recursion guard. */\n private enter(type: Type, refuse: Refuse): SubsetType {\n // A type reaching itself, through a field or an element, is refused rather than followed.\n if (this.reading.has(type.id))\n return refuse(`${nameOfType(this.checker, type)} holds itself (a recursive type)`);\n if (this.reading.size >= maxDepth)\n return refuse(\n `${nameOfType(this.checker, type)} is nested too deep (more than ${maxDepth} levels)`,\n );\n this.reading.add(type.id);\n try {\n const out = this.read(type, refuse);\n this.byId.set(type.id, out);\n return out;\n } finally {\n this.reading.delete(type.id);\n }\n }\n\n private read(type: Type, refuse: Refuse): SubsetType {\n const checker = this.checker;\n const text = () => printType(checker, type);\n const flags = type.flags;\n if (type.isErrorType()) return refuse(`type ${text()}, which does not resolve`);\n if (flags & TypeFlags.Number) return { kind: \"int\" };\n if (flags & (TypeFlags.String | TypeFlags.StringLiteral)) return { kind: \"string\" };\n if (flags & (TypeFlags.Boolean | TypeFlags.BooleanLiteral)) return { kind: \"bool\" };\n if (flags & TypeFlags.Null) return refuse(\"null alone is not a type the subset takes\");\n if (flags & (TypeFlags.Undefined | TypeFlags.Void))\n return refuse(\"undefined in a type (the subset has null)\");\n if (flags & TypeFlags.NumberLiteral)\n return refuse(`the numeric literal type ${text()} (the subset has number)`);\n if (flags & TypeFlags.BigInt) return refuse(\"bigint (the subset has number)\");\n if (flags & TypeFlags.TypeParameter) return refuse(\"type parameters\");\n if (type.isUnionType()) return this.union(type, refuse);\n if (type.isIntersectionType()) return refuse(\"an intersection type\");\n if (!type.isObjectType())\n return refuse(\n `type ${text()} (the subset has number, boolean, string, null, and record types, unions and arrays of them)`,\n );\n if (checker.isArrayType(type)) {\n const element = checker.getTypeArguments(type as TypeReference)[0];\n if (!element) return refuse(`type ${text()}`);\n return { kind: \"list\", element: this.of(element, refuse) };\n }\n if (type.isTupleType()) return refuse(\"a tuple type\");\n if (type.getCallSignatures().length > 0 || type.getConstructSignatures().length > 0)\n return refuse(\"a function type\");\n if (type.getIndexInfos().length > 0) return refuse(\"an index signature\");\n const why = notPlain(checker, type);\n if (why !== undefined) return refuse(`type ${text()} is outside the subset: ${why}`);\n const record = this.record(type, nameOfType(checker, type), refuse);\n return { kind: \"record\", name: record.name };\n }\n\n /** A union: `T | null` a nullable, literals their base type, several records a tagged union. */\n private union(type: Type, refuse: Refuse): SubsetType {\n const members = type.isUnionType() ? type.getTypes() : [type];\n if (members.some((m) => (m.flags & (TypeFlags.Undefined | TypeFlags.Void)) !== 0))\n return refuse(\"undefined in a type (the subset has null)\");\n const nulls = members.filter((m) => (m.flags & TypeFlags.Null) !== 0);\n const rest = members.filter((m) => (m.flags & TypeFlags.Null) === 0);\n const bare = nulls.length === 0 ? type : type.getNonNullableType();\n let base: SubsetType;\n if (rest.length === 0) return refuse(\"null alone is not a type the subset takes\");\n else if (rest.every((m) => (m.flags & (TypeFlags.String | TypeFlags.StringLiteral)) !== 0))\n base = { kind: \"string\" };\n else if (rest.every((m) => (m.flags & (TypeFlags.Boolean | TypeFlags.BooleanLiteral)) !== 0))\n base = { kind: \"bool\" };\n else if (rest.length === 1) base = this.of(rest[0] as Type, refuse);\n else if (rest.every((m) => m.isObjectType() && !this.checker.isArrayType(m)))\n base = this.taggedUnion(bare, rest, refuse);\n else if (rest.some((m) => m.isObjectType()))\n return refuse(\"a union mixing records with other types\");\n else if (rest.every((m) => (m.flags & TypeFlags.NumberLiteral) !== 0))\n return refuse(\n `the numeric literal type ${printType(this.checker, type)} (the subset has number)`,\n );\n else\n return refuse(\n `a union of several types (${printType(this.checker, type)}): the subset has a union of literals of one kind, a tagged union of records, and either with null`,\n );\n if (nulls.length === 0) return base;\n if (base.kind === \"nullable\") return base;\n return { kind: \"nullable\", inner: base };\n }\n\n /**\n * A union of records, told apart by a tag: a literal-typed field every\n * member has, holding a different literal in each. Members declared\n * inline are named by the union and their tag (`Outcome.true`); a\n * record declared on its own keeps its name, and may be a member of several unions.\n */\n private taggedUnion(type: Type, members: readonly Type[], refuse: Refuse): SubsetType {\n const cached = this.byId.get(type.id);\n if (cached) return cached;\n const checker = this.checker;\n const name = nameOfType(checker, type);\n // One name, one type: a second union of the name, or a record of it, is a clash.\n const taken = this.idOfName.get(name);\n if (taken !== undefined && taken !== type.id) return refuse(`two types named ${name}`);\n if (taken === undefined && (this.records.has(name) || this.unions.some((u) => u.name === name)))\n return refuse(`two types named ${name}`);\n const literalFields = (m: Type): Map<string, string | boolean> => {\n const out = new Map<string, string | boolean>();\n for (const p of m.getProperties()) {\n const t = checker.getTypeOfSymbol(p);\n if (t.isStringLiteralType() || t.isBooleanLiteralType()) out.set(p.name, t.value);\n }\n return out;\n };\n const literals = members.map(literalFields);\n const tag = [...(literals[0] as Map<string, string | boolean>).keys()].find(\n (field) =>\n literals.every((l) => l.has(field)) &&\n new Set(literals.map((l) => JSON.stringify(l.get(field)))).size === literals.length,\n );\n if (tag === undefined)\n return refuse(\n `${name}: a union of records without a tag (a literal-typed field every member has, different in each)`,\n );\n const isAnonymous = (m: Type) =>\n !m.getAliasSymbol() &&\n ((m.getSymbol()?.flags ?? 0) & (SymbolFlags.Interface | SymbolFlags.Class)) === 0;\n const read = members.map((m, i) => {\n const value = (literals[i] as Map<string, string | boolean>).get(tag) as string | boolean;\n const memberName = isAnonymous(m) ? `${name}.${String(value)}` : nameOfType(checker, m);\n const record = this.record(m, memberName, refuse, name);\n return { tag: value, record: record.name };\n });\n const union: UnionType = { name, tag, members: read };\n this.unions.push(union);\n this.idOfName.set(name, type.id);\n const out: SubsetType = { kind: \"union\", name };\n this.byId.set(type.id, out);\n return out;\n }\n\n /** A record under `name`: its fields read, the record kept; a member of `union` when given. */\n private record(type: Type, name: string, refuse: Refuse, union?: string): RecordType {\n let known = this.records.get(name);\n // A union of the name is a clash: one name, one type.\n if (!known && this.unions.some((u) => u.name === name))\n return refuse(`two types named ${name}`);\n if (known && this.idOfName.get(name) !== type.id) {\n // Another compiler type of the same name (an inline type written twice, say) is the same\n // record when it has the same fields, and a clash otherwise.\n const fields = this.fieldsOf(type, name, refuse);\n if (JSON.stringify(fields) !== JSON.stringify(known.fields))\n return refuse(`two types named ${name}`);\n this.byId.set(type.id, { kind: \"record\", name });\n }\n if (known) {\n if (union !== undefined && !known.unions?.includes(union)) {\n known = { ...known, unions: [...(known.unions ?? []), union] };\n this.records.set(name, known);\n }\n return known;\n }\n const fields = this.fieldsOf(type, name, refuse);\n const record: RecordType = {\n name,\n fields,\n ...(union === undefined ? {} : { unions: [union] }),\n };\n this.records.set(name, record);\n this.idOfName.set(name, type.id);\n this.byId.set(type.id, { kind: \"record\", name });\n return record;\n }\n\n /** The fields of a record type, each a stored value the subset takes. */\n private fieldsOf(type: Type, name: string, refuse: Refuse): Field[] {\n // A member read straight from its union is guarded here; one read through `of` already is.\n const guard = !this.reading.has(type.id);\n if (guard) this.reading.add(type.id);\n try {\n const checker = this.checker;\n const fields: Field[] = [];\n const outside: Refuse = (what) => refuse(`type ${name} is outside the subset: ${what}`);\n for (const p of type.getProperties()) {\n if (isSymbolKey(p.name)) return outside(\"a field keyed by a symbol\");\n if ((p.flags & SymbolFlags.Optional) !== 0) return outside(`optional field ${p.name}`);\n if ((p.flags & SymbolFlags.Method) !== 0) return outside(`a method ${p.name}`);\n // A getter computes; a stored field it is not.\n if ((p.flags & (SymbolFlags.GetAccessor | SymbolFlags.SetAccessor)) !== 0)\n return outside(`an accessor ${p.name}`);\n if (structureNames.has(p.name))\n return outside(`field ${p.name} takes a name Lean's structures reserve`);\n if (p.name === \"__proto__\")\n return outside(\"a field named __proto__, which JavaScript treats specially\");\n const fieldType = checker.getTypeOfSymbol(p);\n const read = this.of(fieldType, (what) => outside(`field ${p.name}: ${what}`));\n const literal = fieldType.isStringLiteralType()\n ? fieldType.value\n : fieldType.isBooleanLiteralType()\n ? fieldType.value\n : undefined;\n fields.push({ name: p.name, type: read, ...(literal === undefined ? {} : { literal }) });\n }\n return fields;\n } finally {\n if (guard) this.reading.delete(type.id);\n }\n }\n}\n","/**\n * The pure TypeScript subset the first-party engines accept, read into a\n * small tree: exported functions (declarations, and arrows a module-level\n * `const` holds) over `number`, `boolean` and `string`,\n * record types, nullable types (`T | null`) and tagged unions of records,\n * lists of any of those, returning any of those; bodies made of `const`\n * bindings, `if` with early returns, `return`, and expressions from\n * arithmetic (`+ - *`), comparisons, `=== !==` (`null` included, which\n * narrows a nullable name in the branch it guards), `&& || !`, the\n * conditional operator, record and array literals, field reads (on a\n * union, only a field every member has), list methods and calls to the\n * module's own functions. Types are whatever the compiler resolves them\n * to: declared anywhere in the file, imported from another file, or an\n * instantiated generic. Anything else is `OutsideSubset`, with the\n * construct named: the subset is specified by the contract corpus and\n * widens one characterised class at a time. What each engine takes of it\n * is the engine's business (`restrictModule`). This module holds the\n * reads: a module through the compiler (`readSubset`), an expression or a\n * spec arrow from its text (`readExpression`, `readArrowBody`). The tree\n * is in `tree.ts`, typing in `typing.ts`, narrowing in `narrowing.ts`,\n * renaming in `rename.ts`, restriction in `restrict.ts`; `expressions.ts`\n * reads the syntax, `types.ts` the compiler's types, `declarations.ts` a\n * file's functions, and `inline.ts` the calls read as their callee's body.\n */\n\nimport type { Arrow } from \"@eutaxy/spec\";\nimport {\n type Expression,\n InternalSymbolName,\n type Node,\n type ObjectLiteralExpression,\n type SourceFile,\n} from \"typescript/ast\";\nimport * as is from \"typescript/ast/is\";\nimport type { Checker, Type } from \"typescript/sync\";\nimport { type InputFile, textOf, withProgram, withSourceFile } from \"./compiler.ts\";\nimport {\n type Declared,\n declaration,\n fileFunctions,\n type Head,\n head,\n notCompiled,\n rangeOf,\n} from \"./declarations.ts\";\nimport { blockOf, ExprReader, type Names, syntacticType, type TypeSource } from \"./expressions.ts\";\nimport { inliner } from \"./inline.ts\";\nimport {\n callees,\n children,\n type Expr,\n type OutsideFunction,\n OutsideSubset,\n type RecordType,\n type SubsetFunction,\n type SubsetModule,\n type SubsetType,\n type UnionType,\n} from \"./tree.ts\";\nimport { SubsetTypes } from \"./types.ts\";\nimport type { CalleeSignature, TypeContext } from \"./typing.ts\";\n\n/** The path a module read from text alone is compiled under: an import of another file does not resolve from it. */\nconst virtualModulePath = \"/eutaxy/reader/module.ts\";\n\nexport interface ReadSubsetOptions {\n /** The module's path on disk, under which its imports resolve. Without it the module stands alone. */\n readonly path?: string;\n /** Other files the read sees in place of (or beside) the files on disk, by path. */\n readonly files?: readonly InputFile[];\n}\n\n/** What typing a module's expressions needs, shared by every function read. */\nfunction moduleContext(\n records: Map<string, RecordType>,\n unions: readonly UnionType[],\n): {\n ctx: TypeContext;\n signatures: Map<string, CalleeSignature>;\n} {\n const signatures = new Map<string, CalleeSignature>();\n return { ctx: { records, unions, signatures }, signatures };\n}\n\n/** The contextual type the compiler gives a record literal, as the subset reads it; undefined where it has none the subset takes. */\nfunction contextualType(\n checker: Checker,\n types: SubsetTypes,\n node: ObjectLiteralExpression,\n): SubsetType | undefined {\n const type = checker.getContextualType(node);\n if (!type) return undefined;\n // A context inferred from the literal itself (a callback's result, say) declares nothing: the\n // literal is matched against the declared records instead.\n const fromLiteral = (t: Type): boolean =>\n t.isObjectType() && t.getSymbol()?.name === InternalSymbolName.Object;\n if (fromLiteral(type) || (type.isUnionType() && type.getTypes().some(fromLiteral)))\n return undefined;\n const skip = Symbol(\"outside\");\n try {\n const read = types.of(type, () => {\n throw skip;\n });\n return read.kind === \"nullable\" ? read.inner : read;\n } catch (err) {\n if (err === skip) return undefined;\n throw err;\n }\n}\n\n/**\n * Read a module: every function the subset takes (in source order, so\n * callees come before callers), the record types and unions they use,\n * and, for the other functions, why not. A function calling one outside\n * the subset is outside it too. The names given are what the caller\n * cares about; one the module does not declare at its top level is\n * reported among the others, not thrown.\n */\nexport function readSubset(\n source: string,\n functions?: readonly string[],\n options: ReadSubsetOptions = {},\n): SubsetModule {\n const path = options.path ?? virtualModulePath;\n return withProgram(\n [{ path, text: source }, ...(options.files ?? [])],\n ({ checker, file, parseError, typeErrors, standardGlobal }) => {\n const sf = file(path);\n // Pass 1: the module's top-level functions, and what makes them untrustworthy. A generic one is\n // no function of the subset (no claim is stated over a type parameter); its callers read it inlined.\n const own = fileFunctions(sf, checker, standardGlobal);\n const { declarations, overloaded } = own;\n const declared = new Set(declarations.keys());\n const generic = new Set(\n [...declarations].filter(([, d]) => d.node.typeParameters).map(([name]) => name),\n );\n const outside = new Map<string, OutsideFunction>();\n const error = parseError(path);\n // Source the compiler cannot parse is source the reader cannot trust: every function is outside.\n if (error) {\n for (const name of new Set([...declared, ...(functions ?? [])]))\n outside.set(name, {\n name,\n line: 0,\n message: `the module could not be parsed: ${error.message} (line ${error.line})`,\n });\n return { records: [], unions: [], functions: [], outside: [...outside.values()] };\n }\n // A name asked for that is no module-level declaration (inside a namespace, say) is reported, not thrown.\n for (const name of functions ?? [])\n if (!declared.has(name))\n outside.set(name, {\n name,\n line: 0,\n message: `the module declares no function ${name} at its top level`,\n });\n for (const [name, why] of own.untrusted) if (!outside.has(name)) outside.set(name, why);\n // The module's own declared types first, in their order, so a record literal of no declared type\n // is matched against every record the module declares, and a record belongs to the union declared\n // first. A declared type the subset does not take is left out here; a function using it says why.\n const types = new SubsetTypes(checker);\n const skip = Symbol(\"outside\");\n for (const st of sf.statements) {\n if (!is.isInterfaceDeclaration(st) && !is.isTypeAliasDeclaration(st)) continue;\n if (st.typeParameters) continue; // a generic alias is read where it is instantiated\n const symbol = checker.getSymbolAtLocation(st.name);\n if (!symbol) continue;\n try {\n types.of(checker.getDeclaredTypeOfSymbol(symbol), () => {\n throw skip;\n });\n } catch (err) {\n if (err !== skip) throw err;\n }\n }\n // Pass 2: signatures, so every function's return type is known before any body is read.\n const { ctx, signatures } = moduleContext(types.records, types.unions);\n const names: Names = {\n callable: (n) => declared.has(n) && !generic.has(n),\n target: (n) => n,\n declared: (n) => declared.has(n),\n spec: false,\n global: standardGlobal,\n };\n const typeSource: TypeSource = {\n annotation: (node, refuse) => types.of(checker.getTypeAtLocation(node), refuse),\n contextual: (node) => contextualType(checker, types, node),\n };\n const { inline, constant } = inliner({\n checker,\n types,\n typeSource,\n ctx,\n module: sf,\n own,\n parseError,\n typeErrors,\n standardGlobal,\n });\n const reader = new ExprReader(sf, names, typeSource, ctx, undefined, inline, constant);\n const heads: Head[] = [];\n for (const [name, decl] of declarations) {\n try {\n if (overloaded.has(name))\n reader.fail(`${name} is declared more than once (overloads)`, decl.statement);\n const h = head(reader, types, checker, decl);\n // Callers of an assigned function still type-check against its declaration; they are then outside with it.\n signatures.set(name, { params: h.params, returns: h.returns });\n if (!outside.has(name)) heads.push(h);\n } catch (err) {\n if (!(err instanceof OutsideSubset)) throw err;\n if (!outside.has(name)) outside.set(name, { name, line: err.line, message: err.message });\n }\n }\n // Pass 3: bodies. Text the compiler rejects (a const used before its declaration, which\n // throws where the reader sees a value) may compute something other than what it says: a\n // function read fine is still outside, with the compiler's message, when it has such an error.\n const read = new Map<string, SubsetFunction>();\n for (const h of heads) {\n try {\n const fn = declaration(reader, h);\n const bad = notCompiled(sf, typeErrors, rangeOf(declarations.get(h.name) as Declared));\n if (bad) throw new OutsideSubset(bad.message, bad.line);\n read.set(h.name, fn);\n } catch (err) {\n if (!(err instanceof OutsideSubset)) throw err;\n outside.set(h.name, { name: h.name, line: err.line, message: err.message });\n }\n }\n closeOverCallees(read, outside);\n // Recursion is in the subset as structural recursion on a list (`structuralOn`), a function calling\n // itself directly; any other recursion is outside, and so are its callers.\n const reaches = (from: string, target: string, seen = new Set<string>()): boolean => {\n const fn = read.get(from);\n if (!fn) return false;\n for (const c of callees(fn.body)) {\n if (c === target) return true;\n if (!seen.has(c)) {\n seen.add(c);\n if (reaches(c, target, seen)) return true;\n }\n }\n return false;\n };\n for (const [name, fn] of [...read])\n if (reaches(name, name)) {\n const direct = [...callees(fn.body)].every((c) => c === name || !reaches(c, name));\n const on = direct ? structuralOn(fn) : undefined;\n if (on !== undefined) {\n read.set(name, { ...fn, structural: on });\n continue;\n }\n read.delete(name);\n outside.set(name, {\n name,\n line: fn.line,\n message: `${name} is recursive in a way the subset does not take: it takes a function calling itself on a list parameter's slice(1), after a first test of that list's length against 0 (if (xs.length === 0) return …)`,\n });\n }\n closeOverCallees(read, outside);\n // Callees before callers, whatever the source order: Lean needs a definition before its use.\n const ordered: SubsetFunction[] = [];\n const placed = new Set<string>();\n while (ordered.length < read.size)\n // A structurally recursive function calls itself: that callee needs no placing first.\n for (const [name, fn] of read)\n if (\n !placed.has(name) &&\n [...callees(fn.body)].every((c) => c === name || placed.has(c))\n ) {\n ordered.push(fn);\n placed.add(name);\n }\n return {\n records: [...types.records.values()],\n unions: types.unions,\n functions: ordered,\n outside: [...outside.values()],\n };\n },\n );\n}\n\n/** A caller of a function outside the subset is outside it too, however many steps away. */\nfunction closeOverCallees(\n read: Map<string, SubsetFunction>,\n outside: Map<string, OutsideFunction>,\n): void {\n for (let changed = true; changed; ) {\n changed = false;\n for (const [name, fn] of read) {\n const bad = [...callees(fn.body)].find((c) => outside.has(c));\n if (bad === undefined) continue;\n read.delete(name);\n outside.set(name, {\n name,\n line: fn.line,\n message: `calls ${bad}, which is outside the subset: ${outside.get(bad)?.message}`,\n });\n changed = true;\n }\n }\n}\n\n/**\n * A reader over text that is not the module: with `aliases`, the text is\n * a spec file's, whose names for the module's functions are its own\n * imports and nothing else; without, the text sees the module's names.\n * No compiler stands behind the text, so a `const` annotation is read\n * from its syntax against the module's declared types, and a record\n * literal has no contextual type. Lines are not reported: the text's\n * position is the caller's to know.\n */\nfunction arrowReader(\n sf: SourceFile,\n module: SubsetModule,\n aliases?: ReadonlyMap<string, string>,\n): ExprReader {\n const records = new Map(module.records.map((rec) => [rec.name, rec]));\n const unionNames = new Set(module.unions.map((u) => u.name));\n const inSubset = new Set(module.functions.map((f) => f.name));\n let names: Names;\n if (aliases) {\n const declared = new Set(aliases.keys());\n const callable = new Set(\n [...aliases].filter(([, fn]) => inSubset.has(fn)).map(([local]) => local),\n );\n names = {\n callable: (n) => callable.has(n),\n target: (n) => aliases.get(n) ?? n,\n declared: (n) => declared.has(n),\n spec: true,\n global: () => true,\n };\n } else {\n const declared = new Set([...inSubset, ...module.outside.map((o) => o.name)]);\n names = {\n callable: (n) => inSubset.has(n),\n target: (n) => n,\n declared: (n) => declared.has(n),\n spec: false,\n global: () => true,\n };\n }\n const recordNames = new Set(records.keys());\n const typeSource: TypeSource = {\n annotation: (node, refuse) => syntacticType(sf, node, recordNames, unionNames, refuse),\n contextual: () => undefined,\n };\n const signatures = new Map<string, CalleeSignature>(\n module.functions.map((f) => [f.name, { params: f.params, returns: f.returns }]),\n );\n return new ExprReader(\n sf,\n names,\n typeSource,\n { records, unions: module.unions, signatures },\n () => 0,\n );\n}\n\n/** The one expression a fragment `(text)` parsed to, or why the text is not one expression. */\nfunction fragmentExpression(sf: SourceFile): Expression {\n const [first, second] = sf.statements;\n if (second) throw new OutsideSubset(`unexpected ${textOf(sf, second)} after the expression`, 0);\n if (!first || !is.isExpressionStatement(first) || !is.isParenthesizedExpression(first.expression))\n throw new OutsideSubset(\"could not be parsed as an expression\", 0);\n let broken: string | undefined;\n const visit = (node: Node): void => {\n if (broken !== undefined) return;\n if (is.isIdentifier(node) && node.text === \"\")\n broken = \"could not be parsed (something is missing)\";\n node.forEachChild(visit);\n };\n visit(first);\n if (broken !== undefined) throw new OutsideSubset(broken, 0);\n return first.expression.expression;\n}\n\n/**\n * One TypeScript expression (a claim's body, say) in a scope of typed\n * names, over a module already read. The whole text must be the\n * expression.\n */\nexport function readExpression(\n text: string,\n scope: ReadonlyMap<string, SubsetType>,\n module: SubsetModule,\n aliases?: ReadonlyMap<string, string>,\n): Expr {\n return withSourceFile(`(${text}\\n)`, (sf) => {\n const expr = fragmentExpression(sf);\n return arrowReader(sf, module, aliases).expression(expr, scope);\n });\n}\n\n/**\n * The body of a spec file's arrow (`when` or `ensures`) as a boolean\n * expression: an expression body as it is, a block body through the same\n * statement reader as a function body (`const`, `if`, early returns).\n * The scope maps the arrow's own parameter names to the binders' types;\n * `aliases` maps the spec file's local names to the module's functions,\n * and a free name that is neither is outside the subset: the spec file's\n * scope is its imports, never the module's. `Math` and `Number` are the\n * globals wherever the arrow's own scope does not bind them: `readSpecs`\n * has checked that every built-in a claim names resolves to the standard\n * library in the spec file.\n */\nexport function readArrowBody(\n arrow: Arrow,\n scope: ReadonlyMap<string, SubsetType>,\n module: SubsetModule,\n aliases: ReadonlyMap<string, string> = new Map(),\n): Expr {\n if (!arrow.block)\n return withSourceFile(`(${arrow.body}\\n)`, (sf) => {\n const expr = fragmentExpression(sf);\n const reader = arrowReader(sf, module, aliases);\n return reader.narrowed(reader.expression(expr, scope), scope, sf);\n });\n return withSourceFile(`{${arrow.body}\\n}`, (sf) => {\n const block = blockOf(sf);\n if (!block) throw new OutsideSubset(\"could not be parsed as a block\", 0);\n const reader = arrowReader(sf, module, aliases);\n return reader.narrowed(reader.block(block.statements, new Map(scope), block), scope, sf);\n });\n}\n\n/**\n * The list parameter a function recurses on structurally, or undefined:\n * its body is `if (p.length === 0) … else …` for a list parameter p, the\n * test and the first branch do not call it, and every call to it in the\n * other branch passes `p.slice(1)` for p. Lean takes such a definition as\n * a match on `[]` and `head :: tail`, recursing on the tail.\n */\nfunction structuralOn(fn: SubsetFunction): number | undefined {\n const body = fn.body;\n if (body.kind !== \"cond\") return undefined;\n const t = body.test;\n if (t.kind !== \"binary\" || t.op !== \"===\") return undefined;\n const sides = [t.left, t.right];\n const zero = sides.find((x) => x.kind === \"int\" && x.value === \"0\");\n const len = sides.find((x) => x !== zero);\n if (!zero || len?.kind !== \"field\" || len.field !== \"length\" || len.object.kind !== \"var\")\n return undefined;\n const list = len.object.name;\n const at = fn.params.findIndex((p) => p.name === list && p.type.kind === \"list\");\n if (at < 0) return undefined;\n if (callees(t).has(fn.name) || callees(body.ifTrue).has(fn.name)) return undefined;\n const calls = selfCalls(body.ifFalse, fn.name);\n const onTail = (a: Expr | undefined) =>\n a?.kind === \"tail\" && a.list.kind === \"var\" && a.list.name === list;\n return calls.length > 0 && calls.every((c) => onTail(c.args[at])) ? at : undefined;\n}\n\n/** Every call to `name` in an expression. */\nfunction selfCalls(e: Expr, name: string): Extract<Expr, { kind: \"call\" }>[] {\n const out: Extract<Expr, { kind: \"call\" }>[] = [];\n const walk = (x: Expr): void => {\n if (x.kind === \"call\" && x.callee === name) out.push(x);\n for (const child of children(x)) walk(child);\n };\n walk(e);\n return out;\n}\n","/**\n * A module as one first-party engine takes it: the functions to report on,\n * the subset read from the source and restricted to what the engine takes,\n * and the functions outside it with why. Every engine opens with this, so\n * what an engine translates has one reading to stand on, and a user reads\n * the same reason whichever engine gave it.\n */\n\nimport type { FunctionSpec } from \"@eutaxy/spec\";\nimport { type PropertyProof, type ProveInput, proofsOf, unknownOutcome } from \"../provers.ts\";\nimport { restrictModule } from \"./restrict.ts\";\nimport { readSubset } from \"./subset.ts\";\nimport type { Expr, SubsetModule, SubsetType } from \"./tree.ts\";\n\n/** One thing an engine does not take, as `restrictModule` applies it. */\nexport interface EngineRestriction {\n /** The types the engine takes. */\n readonly takes: (t: SubsetType) => boolean;\n /** Why a function that falls to this restriction is outside. */\n readonly reason: string;\n /** Expression kinds a body may not hold: by default what nullable types and unions bring. */\n readonly bodies?: ReadonlySet<Expr[\"kind\"]>;\n /** A body the engine refuses for what it computes, not its kinds or types (a division, say). */\n readonly refused?: (body: Expr) => boolean;\n}\n\n/** A module read for an engine. */\nexport interface EngineModule {\n /** The module as the engine sees it, its restrictions applied in order. */\n readonly module: SubsetModule;\n /** The functions to report on: the ones asked for among those with specs. */\n readonly fns: readonly FunctionSpec[];\n /** Those of them the engine does not take, with the reason; an engine adds what its emitter refuses (`engineGap`). */\n readonly outside: Map<string, string>;\n}\n\n/**\n * Read a module for an engine: the functions asked for (every one with\n * specs when none are named), the subset restricted by each of the\n * engine's restrictions in order, and the functions outside it, by the\n * reader's reason or because the spec names a declaration that is not the\n * module's top-level one of that name.\n */\nexport function readForEngine(\n input: Pick<ProveInput, \"source\" | \"specs\" | \"functions\" | \"modulePath\">,\n restrictions: readonly EngineRestriction[],\n): EngineModule {\n const wanted = input.functions ? new Set(input.functions) : undefined;\n const fns = input.specs.functions.filter((f) => !wanted || wanted.has(f.name));\n let module = readSubset(\n input.source,\n fns.map((f) => f.name),\n input.modulePath === undefined ? {} : { path: input.modulePath },\n );\n for (const r of restrictions)\n module = restrictModule(module, r.takes, r.reason, r.bodies, r.refused);\n const outside = new Map<string, string>();\n for (const o of module.outside)\n if (fns.some((f) => f.name === o.name))\n outside.set(\n o.name,\n `outside the engine's subset${o.line > 0 ? ` (line ${o.line})` : \"\"}: ${o.message}`,\n );\n // A spec belongs to one declaration: the one the reader found at that offset. A nested function (in a\n // namespace, say) named like a top-level one must not lend its properties to the top-level body.\n for (const fn of fns) {\n const read = module.functions.find((f) => f.name === fn.name);\n if (read && read.offset !== fn.offset)\n outside.set(\n fn.name,\n `outside the engine's subset (line ${fn.line}): the ${fn.name} the spec names is not the module's top-level declaration of that name (line ${read.line})`,\n );\n }\n return { module, fns, outside };\n}\n\n/**\n * The emitter refused something the reader let through: an engine gap, so\n * every function is outside with that reason and none is guessed.\n */\nexport function engineGap(read: EngineModule, message: string): void {\n for (const fn of read.fns) read.outside.set(fn.name, `outside the engine's subset: ${message}`);\n}\n\n/** The outcomes of the functions outside the engine's subset: `unsupported`, each with its reason. */\nexport function outsideProofs(\n fns: readonly FunctionSpec[],\n outside: ReadonlyMap<string, string>,\n): PropertyProof[] {\n return proofsOf(\n fns.filter((f) => outside.has(f.name)),\n (f) => unknownOutcome(\"unsupported\", outside.get(f.name) as string),\n );\n}\n","/**\n * A module and its spec file read into `ModuleSpecs` through the\n * compiler. From the module: the exported functions and their parameter\n * types (`function` declarations and `const` arrows alike), the types as\n * the compiler resolves them. From the spec file: every\n * `export const name = forall(f, { sample, when, ensures })` and\n * `total(f)`, with the combinators imported from `eutaxy/spec` and `f`\n * imported from the module beside the spec file (the import resolved by\n * the compiler); the arrows are kept as text, their parameter names\n * naming the binders, and the precondition's conjuncts about one\n * parameter become that binder's hint. Anything else is an error with a\n * line, never a guess.\n */\n\nimport type {\n Arrow,\n Binder,\n Endpoint,\n FunctionSpec,\n Hint,\n ModuleSpecs,\n Param,\n Property,\n SpecError,\n SpecType,\n} from \"@eutaxy/spec\";\nimport {\n type ArrowFunction,\n type Expression,\n type FunctionLikeBase,\n type ImportDeclaration,\n type Node,\n type SourceFile,\n SyntaxKind,\n} from \"typescript/ast\";\nimport * as is from \"typescript/ast/is\";\nimport type { Checker, Program } from \"typescript/sync\";\nimport { endpointBigInt, endpointNumber } from \"../generate.ts\";\nimport {\n isAsync,\n isConst,\n isExported,\n lineAt,\n type Opened,\n openParen,\n textOf,\n withProgram,\n withSourceFile,\n} from \"./compiler.ts\";\nimport { rebound } from \"./rebinding.ts\";\nimport { specTypeOf, unionOf } from \"./types.ts\";\n\nexport interface ReadSpecsInput {\n /** The module's source. */\n readonly module: string;\n /** The spec file's source. */\n readonly spec: string;\n /**\n * The module's path, under which its imports resolve; the spec file\n * is beside it unless `specPath` says otherwise. For a module given\n * by text alone, any absolute path the spec file's import of the\n * module resolves to (`/x/domain.ts` for `import … from \"./domain.ts\"`).\n */\n readonly modulePath: string;\n /** The spec file's path; `<module>.props.ts` by default. */\n readonly specPath?: string;\n /** Specifiers the combinators come from; `eutaxy/spec` and the workspace name by default. */\n readonly specSpecifiers?: readonly string[];\n}\n\n// ---------------------------------------------------------------------------\n// The module: exported functions and their parameter types.\n\ninterface Declaration {\n readonly name: string;\n readonly params: readonly Param[];\n readonly line: number;\n readonly offset: number;\n}\n\ninterface ModuleSide {\n readonly declarations: ReadonlyMap<string, Declaration>;\n /** Exported name to local declaration name. */\n readonly exports: ReadonlyMap<string, string>;\n readonly errors: readonly SpecError[];\n}\n\n/** The parameters of a function-like declaration: `name?: T = default`, `...rest`, destructured. */\nfunction readParams(checker: Checker, fn: FunctionLikeBase): Param[] {\n const params: Param[] = [];\n for (const p of fn.parameters) {\n const name = is.isIdentifier(p.name) ? p.name.text : null;\n if (name === \"this\") continue; // a receiver annotation, no argument\n if (p.dotDotDotToken) {\n params.push({ name: null, type: { kind: \"unknown\", text: `...${name ?? \"\"}` } });\n continue;\n }\n let type: SpecType;\n if (p.type) type = specTypeOf(checker, checker.getTypeAtLocation(p.type));\n else if (p.initializer) type = specTypeOf(checker, checker.getTypeAtLocation(p));\n else type = { kind: \"unknown\", text: \"(no type annotation)\" };\n // An optional parameter, or one with a default, may be passed undefined.\n if (p.questionToken || p.initializer) type = unionOf([type, { kind: \"undefined\" }]);\n params.push({ name, type });\n }\n return params;\n}\n\nfunction readModuleSide(sf: SourceFile, checker: Checker): ModuleSide {\n const errors: SpecError[] = [];\n const declarations = new Map<string, Declaration>();\n const exports = new Map<string, string>();\n const declare = (name: string, fn: FunctionLikeBase, at: Node): void => {\n const offset = openParen(sf, fn);\n if (offset === undefined) return; // an arrow without parentheses: no parameter list to point at\n if (declarations.has(name)) {\n errors.push({\n line: lineAt(sf, at),\n message: `${name} is declared more than once (overloads): a spec is checked against one signature`,\n inModule: true,\n });\n return;\n }\n declarations.set(name, { name, params: readParams(checker, fn), line: lineAt(sf, at), offset });\n };\n for (const st of sf.statements) {\n if (is.isFunctionDeclaration(st)) {\n if (!st.name) continue;\n declare(st.name.text, st, st);\n if (isExported(st)) exports.set(st.name.text, st.name.text);\n continue;\n }\n if (is.isVariableStatement(st)) {\n // `export const f = (a: T): R => …` or `= function (a: T) …`: a function by another declaration.\n for (const d of st.declarationList.declarations) {\n if (!is.isIdentifier(d.name) || !d.initializer) continue;\n let init: Expression = d.initializer;\n while (is.isParenthesizedExpression(init)) init = init.expression;\n if (!is.isArrowFunction(init) && !is.isFunctionExpression(init)) continue;\n declare(d.name.text, init, st);\n if (isExported(st)) exports.set(d.name.text, d.name.text);\n }\n continue;\n }\n // `export { a, b as c }`; with `from`, a re-export of another module's names (not this module's).\n if (is.isExportDeclaration(st) && !st.moduleSpecifier && !st.isTypeOnly && st.exportClause) {\n if (!is.isNamedExports(st.exportClause)) continue;\n for (const e of st.exportClause.elements) {\n if (e.isTypeOnly) continue;\n const local = e.propertyName ?? e.name;\n if (is.isIdentifier(local) && is.isIdentifier(e.name)) exports.set(e.name.text, local.text);\n }\n }\n }\n return { declarations, exports, errors };\n}\n\n// ---------------------------------------------------------------------------\n// The spec file.\n\ninterface Imported {\n readonly from: string;\n /** The exported name imported; `*` for a namespace import. */\n readonly name: string;\n readonly declaration: ImportDeclaration;\n}\n\n/** `import { a, b as c } from \"x\"`, `import * as ns from \"x\"`, `import d from \"x\"`; type-only imports skipped. */\nfunction imports(sf: SourceFile): Map<string, Imported> {\n const out = new Map<string, Imported>();\n for (const st of sf.statements) {\n if (!is.isImportDeclaration(st) || !st.importClause) continue;\n const clause = st.importClause;\n if (clause.phaseModifier === SyntaxKind.TypeKeyword) continue;\n if (!is.isStringLiteral(st.moduleSpecifier)) continue;\n const from = st.moduleSpecifier.text;\n if (clause.name) out.set(clause.name.text, { from, name: \"default\", declaration: st });\n const bindings = clause.namedBindings;\n if (!bindings) continue;\n if (is.isNamespaceImport(bindings))\n out.set(bindings.name.text, { from, name: \"*\", declaration: st });\n else\n for (const e of bindings.elements) {\n if (e.isTypeOnly) continue;\n const imported = e.propertyName ?? e.name;\n const name = is.isIdentifier(imported) ? imported.text : imported.text;\n out.set(e.name.text, { from, name, declaration: st });\n }\n }\n return out;\n}\n\n/** `1`, `-1`, `1_000`, `1.5`, `10n` as an endpoint value; undefined otherwise. */\nfunction numberText(sf: SourceFile, node: Expression): string | undefined {\n if (is.isNumericLiteral(node) || is.isBigIntLiteral(node))\n return textOf(sf, node).replace(/_/g, \"\");\n if (\n is.isPrefixUnaryExpression(node) &&\n node.operator === SyntaxKind.MinusToken &&\n (is.isNumericLiteral(node.operand) || is.isBigIntLiteral(node.operand))\n )\n return `-${textOf(sf, node.operand).replace(/_/g, \"\")}`;\n return undefined;\n}\n\n/** The top-level conjuncts of an expression, parentheses stripped. */\nfunction conjuncts(node: Expression, out: Expression[] = []): Expression[] {\n let e = node;\n while (is.isParenthesizedExpression(e)) e = e.expression;\n if (is.isBinaryExpression(e) && e.operatorToken.kind === SyntaxKind.AmpersandAmpersandToken) {\n conjuncts(e.left, out);\n conjuncts(e.right, out);\n } else out.push(e);\n return out;\n}\n\nconst comparisons: Partial<Record<SyntaxKind, string>> = {\n [SyntaxKind.LessThanToken]: \"<\",\n [SyntaxKind.LessThanEqualsToken]: \"<=\",\n [SyntaxKind.GreaterThanToken]: \">\",\n [SyntaxKind.GreaterThanEqualsToken]: \">=\",\n};\n\n/**\n * What an expression says about each of the named parameters on its own:\n * its top-level conjuncts of the forms `Number.isInteger(x)`, `x < n`,\n * `n <= x` (and the other comparisons) and `/re/.test(x)`, by parameter\n * index.\n */\nfunction hintsIn(\n sf: SourceFile,\n body: Expression,\n params: readonly (string | null)[],\n): Map<number, Hint> {\n const out = new Map<number, Hint>();\n const position = new Map<string, number>();\n params.forEach((p, i) => {\n if (p !== null) position.set(p, i);\n });\n const merge = (i: number, h: Hint) => {\n const old = out.get(i) ?? {};\n out.set(i, { ...old, ...h });\n };\n for (const conjunct of conjuncts(body)) {\n if (is.isCallExpression(conjunct)) {\n const callee = conjunct.expression;\n const [arg, extra] = conjunct.arguments;\n if (!is.isPropertyAccessExpression(callee) || !is.isIdentifier(callee.name) || !arg || extra)\n continue;\n if (!is.isIdentifier(arg)) continue;\n const at = position.get(arg.text);\n if (at === undefined) continue;\n // Number.isInteger(x)\n if (\n is.isIdentifier(callee.expression) &&\n callee.expression.text === \"Number\" &&\n callee.name.text === \"isInteger\"\n )\n merge(at, { integer: true });\n // /re/.test(x)\n else if (is.isRegularExpressionLiteral(callee.expression) && callee.name.text === \"test\") {\n const m = /^\\/([\\s\\S]*)\\/([a-z]*)$/.exec(textOf(sf, callee.expression));\n if (m) merge(at, { regex: { pattern: m[1] as string, flags: m[2] as string } });\n }\n continue;\n }\n // x op n, n op x\n if (!is.isBinaryExpression(conjunct)) continue;\n const op = comparisons[conjunct.operatorToken.kind];\n if (op === undefined) continue;\n const bound = (variable: Expression, literal: Expression, variableOnLeft: boolean) => {\n if (!is.isIdentifier(variable)) return;\n const value = numberText(sf, literal);\n if (value === undefined) return;\n const at = position.get(variable.text);\n if (at === undefined) return;\n // `x < n` bounds x above; `n < x` bounds it below.\n const above = variableOnLeft ? op.startsWith(\"<\") : op.startsWith(\">\");\n const endpoint: Endpoint = { value, inclusive: op.endsWith(\"=\") };\n merge(at, above ? { upper: endpoint } : { lower: endpoint });\n };\n if (is.isIdentifier(conjunct.left)) bound(conjunct.left, conjunct.right, true);\n else if (is.isIdentifier(conjunct.right)) bound(conjunct.right, conjunct.left, false);\n }\n return out;\n}\n\n/**\n * What the precondition says about each of its parameters on its own,\n * read from the arrow's text: see `hintsIn`. A block body gives none.\n */\nexport function hintsOf(arrow: Arrow): Map<number, Hint> {\n if (arrow.block) return new Map();\n return withSourceFile(`(${arrow.body}\\n)`, (sf) => {\n const [first, second] = sf.statements;\n if (second || !first || !is.isExpressionStatement(first)) return new Map();\n let e = first.expression;\n while (is.isParenthesizedExpression(e)) e = e.expression;\n return hintsIn(sf, e, arrow.params);\n });\n}\n\ninterface SpecExport {\n readonly name: string;\n readonly kind: \"forall\" | \"total\";\n readonly fn: string;\n readonly sample?: Arrow;\n readonly when?: Arrow;\n readonly ensures?: Arrow;\n readonly text: string;\n readonly line: number;\n /** The hints the sample and the precondition give, combined per binder index. */\n readonly hints: ReadonlyMap<number, Hint>;\n}\n\nclass SpecFail extends Error {\n readonly line: number;\n constructor(message: string, line: number) {\n super(message);\n this.line = line;\n }\n}\n\n/** The module's exports the spec file imports by name, as `local` to exported `name`. */\ninterface ModuleImport {\n readonly local: string;\n readonly name: string;\n}\n\n/** Read the spec file's exports. */\nfunction readSpecSide(\n sf: SourceFile,\n { program, checker, standardGlobal }: Opened,\n modulePath: string,\n moduleKey: string,\n specSpecifiers: ReadonlySet<string>,\n): { specs: SpecExport[]; errors: SpecError[]; imports: ModuleImport[] } {\n const errors: SpecError[] = [];\n const bound = imports(sf);\n const specs: SpecExport[] = [];\n function fail(message: string, at: Node): never {\n throw new SpecFail(message, lineAt(sf, at));\n }\n // Whether an import's specifier resolves to the module beside the spec file.\n const resolvesToModule = new Map<string, boolean>();\n const fromModule = (imp: Imported): boolean => {\n const known = resolvesToModule.get(imp.from);\n if (known !== undefined) return known;\n const resolved = program.getResolvedModuleFromModuleSpecifier(\n imp.declaration.moduleSpecifier as Parameters<\n Program[\"getResolvedModuleFromModuleSpecifier\"]\n >[0],\n sf.fileName,\n );\n const target = resolved ? program.getSourceFile(resolved.resolvedFileName) : undefined;\n const is = target !== undefined && target.path === moduleKey;\n resolvesToModule.set(imp.from, is);\n return is;\n };\n /** The combinator a callee names (`forall`, `ns.forall`), or undefined. */\n const combinator = (callee: Expression): \"forall\" | \"total\" | undefined => {\n if (is.isPropertyAccessExpression(callee)) {\n if (!is.isIdentifier(callee.expression) || !is.isIdentifier(callee.name)) return undefined;\n const ns = bound.get(callee.expression.text);\n const member = callee.name.text;\n if (\n ns?.name === \"*\" &&\n specSpecifiers.has(ns.from) &&\n (member === \"forall\" || member === \"total\")\n )\n return member;\n return undefined;\n }\n if (!is.isIdentifier(callee)) return undefined;\n const imp = bound.get(callee.text);\n if (imp && specSpecifiers.has(imp.from) && (imp.name === \"forall\" || imp.name === \"total\"))\n return imp.name;\n return undefined;\n };\n /** The module function a first argument names, or why not. */\n const functionArg = (arg: Expression | undefined, call: Node): string => {\n if (!arg)\n return fail(\"the first argument must name a function of the module, found the end\", call);\n if (\n is.isPropertyAccessExpression(arg) &&\n is.isIdentifier(arg.expression) &&\n is.isIdentifier(arg.name)\n ) {\n const ns = bound.get(arg.expression.text);\n if (ns?.name === \"*\" && fromModule(ns)) return arg.name.text;\n return fail(`${textOf(sf, arg)} is not a function imported from the module`, arg);\n }\n if (!is.isIdentifier(arg))\n return fail(\n `the first argument must name a function of the module, found ${textOf(sf, arg)}`,\n arg,\n );\n const imp = bound.get(arg.text);\n if (!imp)\n return fail(\n `${arg.text} is not imported from the module (import it from ./${modulePath.split(\"/\").pop()})`,\n arg,\n );\n if (!fromModule(imp))\n return fail(\n `${arg.text} is imported from ${JSON.stringify(imp.from)}, not from the module beside this spec file`,\n arg,\n );\n if (imp.name === \"*\" || imp.name === \"default\")\n return fail(`${arg.text} must be a named import of the module's function`, arg);\n return imp.name;\n };\n /**\n * A claim is read from its arrow's text alone, where `Math` and `Number`\n * are the globals unless the arrow binds them itself: an arrow naming\n * one that resolves to anything else here (a binding of the spec file,\n * an import, a const of the arrow's own block declared after the use)\n * is refused, so a claim is never read as something it does not\n * compute. A parameter or const of the arrow bound before the use is\n * the arrow reader's own name for it (a parameter named `Math` reads as\n * that parameter), and a binding the claims do not name, or a type-only\n * import, is fine.\n */\n const builtins = (arrow: ArrowFunction, node: Node, what: string): void => {\n if (\n is.isPropertyAccessExpression(node) &&\n is.isIdentifier(node.expression) &&\n (node.expression.text === \"Math\" || node.expression.text === \"Number\") &&\n !standardGlobal(node.expression)\n ) {\n const id = node.expression;\n const bound = checker.getSymbolAtLocation(id)?.declarations[0]?.resolve();\n const own =\n bound !== undefined &&\n bound.getSourceFile() === sf &&\n bound.pos >= arrow.pos &&\n bound.end <= arrow.end &&\n bound.getStart(sf) < id.getStart(sf);\n if (!own) {\n const file = bound?.getSourceFile();\n const where =\n bound && file\n ? ` (bound at line ${lineAt(file, bound)}${file === sf ? \"\" : ` of ${file.fileName}`})`\n : \"\";\n fail(\n `${what} names ${id.text}, which is not the global ${id.text} here${where}; rename the binding`,\n id,\n );\n }\n }\n node.forEachChild((child) => builtins(arrow, child, what));\n };\n /** An arrow function: its params, body text and whether the body is a block. */\n const arrow = (node: Expression, what: string): { arrow: Arrow; node: ArrowFunction } => {\n if (!is.isArrowFunction(node))\n return fail(\n `${what} must be an arrow function, found ${textOf(sf, node).split(/\\s/)[0] ?? \"\"}`,\n node,\n );\n if (isAsync(node)) fail(`${what} is an async arrow; it must be synchronous`, node);\n builtins(node, node.body, what);\n // A rest or destructured parameter has no name of its own: the binder keeps the function's.\n const params = node.parameters.map((p) =>\n !p.dotDotDotToken && is.isIdentifier(p.name) ? p.name.text : null,\n );\n const body = node.body;\n const line = lineAt(sf, node);\n if (is.isBlock(body))\n return {\n arrow: {\n params,\n body: sf.text.slice(body.getStart(sf) + 1, body.end - 1),\n block: true,\n line,\n },\n node,\n };\n return { arrow: { params, body: textOf(sf, body), block: false, line }, node };\n };\n for (const st of sf.statements) {\n if (!is.isVariableStatement(st)) continue;\n const exported = isExported(st);\n const constant = isConst(st.declarationList);\n for (const d of st.declarationList.declarations) {\n if (!is.isIdentifier(d.name) || !d.initializer) continue;\n const name = d.name.text;\n // `satisfies`, `as`, `!` and parentheses change nothing at runtime: the call is inside them.\n let init: Expression = d.initializer;\n while (\n is.isParenthesizedExpression(init) ||\n is.isSatisfiesExpression(init) ||\n is.isAsExpression(init) ||\n is.isNonNullExpression(init)\n )\n init = init.expression;\n if (!is.isCallExpression(init)) continue;\n const kind = combinator(init.expression);\n if (!kind) continue;\n const line = lineAt(sf, st);\n try {\n if (!exported) fail(`${name} is a spec but not exported, so nothing would check it`, st);\n if (!constant)\n fail(\n `a spec must be a const export, not ${textOf(sf, st).split(/\\s/)[exported ? 1 : 0] ?? \"let\"}`,\n st,\n );\n const [first, second, third] = init.arguments;\n const fn = functionArg(first, init);\n if (kind === \"total\") {\n if (second) fail(\"total takes the function alone\", second);\n specs.push({ name, kind: \"total\", fn, text: `total(${fn})`, line, hints: new Map() });\n continue;\n }\n if (!second) return fail(\"forall takes the function, then { when, ensures }\", init);\n if (third) return fail(`unexpected ${textOf(sf, third)} after forall's arguments`, third);\n if (!is.isObjectLiteralExpression(second))\n return fail(\n \"forall's second argument must be an object literal { when, ensures }\",\n second,\n );\n let sample: { arrow: Arrow; node: ArrowFunction } | undefined;\n let when: { arrow: Arrow; node: ArrowFunction } | undefined;\n let ensures: { arrow: Arrow; node: ArrowFunction } | undefined;\n for (const prop of second.properties) {\n const key =\n is.isPropertyAssignment(prop) ||\n is.isShorthandPropertyAssignment(prop) ||\n is.isMethodDeclaration(prop)\n ? prop.name\n : undefined;\n const keyName =\n key && is.isIdentifier(key) ? key.text : key ? textOf(sf, key) : textOf(sf, prop);\n if (keyName !== \"sample\" && keyName !== \"when\" && keyName !== \"ensures\")\n fail(`forall's properties are sample, when and ensures, found ${keyName}`, prop);\n if (!is.isPropertyAssignment(prop))\n fail(`${keyName} must be written as ${keyName}: (…) => …`, prop);\n const read = arrow(prop.initializer, keyName);\n if (keyName === \"sample\") {\n if (sample) fail(\"sample is given twice\", prop);\n sample = read;\n } else if (keyName === \"when\") {\n if (when) fail(\"when is given twice\", prop);\n when = read;\n } else {\n if (ensures) fail(\"ensures is given twice\", prop);\n ensures = read;\n }\n }\n if (!ensures) return fail(\"forall needs an ensures\", second);\n // The precondition and the sample both steer the draws, combined per binder.\n const hintsOfArrow = (\n a: { arrow: Arrow; node: ArrowFunction } | undefined,\n ): Map<number, Hint> =>\n a && !is.isBlock(a.node.body) ? hintsIn(sf, a.node.body, a.arrow.params) : new Map();\n const fromSample = hintsOfArrow(sample);\n const fromWhen = hintsOfArrow(when);\n const hints = new Map<number, Hint>();\n for (const i of new Set([...fromSample.keys(), ...fromWhen.keys()])) {\n const h = combineHints(fromWhen.get(i), fromSample.get(i));\n if (h) hints.set(i, h);\n }\n specs.push({\n name,\n kind: \"forall\",\n fn,\n ...(sample ? { sample: sample.arrow } : {}),\n ...(when ? { when: when.arrow } : {}),\n ensures: ensures.arrow,\n text: ensures.arrow.body.replace(/\\s+/g, \" \").trim(),\n line,\n hints,\n });\n } catch (err) {\n if (!(err instanceof SpecFail)) throw err;\n errors.push({ line: err.line, message: `${name}: ${err.message}` });\n }\n }\n }\n const moduleImports: ModuleImport[] = [...bound]\n .filter(([, imp]) => imp.name !== \"*\" && imp.name !== \"default\" && fromModule(imp))\n .map(([local, imp]) => ({ local, name: imp.name }));\n return { specs, errors, imports: moduleImports };\n}\n\n/** The tighter of two endpoints on one side; the first when they cannot be compared. */\nfunction tighter(\n first: Endpoint | undefined,\n second: Endpoint | undefined,\n side: \"lower\" | \"upper\",\n): Endpoint | undefined {\n if (!first) return second;\n if (!second) return first;\n // Integral literals compare exactly (bigints reach past every double); others as doubles.\n const integral = (e: Endpoint) => !/[.eE]/.test(e.value);\n let order: number;\n try {\n if (integral(first) && integral(second)) {\n const a = endpointBigInt(first.value);\n const b = endpointBigInt(second.value);\n order = a === b ? 0 : a > b ? 1 : -1;\n } else {\n const a = endpointNumber(first.value);\n const b = endpointNumber(second.value);\n if (Number.isNaN(a) || Number.isNaN(b)) return first;\n order = a === b ? 0 : a > b ? 1 : -1;\n }\n } catch {\n return first;\n }\n if (order !== 0) return (side === \"lower\" ? order > 0 : order < 0) ? first : second;\n return first.inclusive ? second : first;\n}\n\n/**\n * Two hints on one binder as one: integer when either says so, the\n * tighter bound on each side, the first's regex (two cannot be combined,\n * and the draws are checked against both arrows anyway).\n */\nfunction combineHints(first: Hint | undefined, second: Hint | undefined): Hint | undefined {\n if (!first) return second;\n if (!second) return first;\n const lower = tighter(first.lower, second.lower, \"lower\");\n const upper = tighter(first.upper, second.upper, \"upper\");\n const regex = first.regex ?? second.regex;\n return {\n ...(first.integer || second.integer ? { integer: true as const } : {}),\n ...(lower ? { lower } : {}),\n ...(upper ? { upper } : {}),\n ...(regex ? { regex } : {}),\n };\n}\n\n/** Read a module and its spec file. */\nexport function readSpecs(input: ReadSpecsInput): ModuleSpecs {\n const modulePath = input.modulePath;\n const specPath = input.specPath ?? modulePath.replace(/\\.ts$/, \".props.ts\");\n return withProgram(\n [\n { path: modulePath, text: input.module },\n { path: specPath, text: input.spec },\n ],\n (opened) => {\n const { checker, file, parseError } = opened;\n const moduleError = parseError(modulePath);\n const specError = parseError(specPath);\n const errors: SpecError[] = [];\n if (moduleError)\n errors.push({\n line: moduleError.line,\n message: `the module could not be parsed: ${moduleError.message}`,\n inModule: true,\n });\n if (specError)\n errors.push({\n line: specError.line,\n message: `the spec file could not be parsed: ${specError.message}`,\n });\n if (moduleError || specError) return { functions: [], errors };\n const moduleFile = file(modulePath);\n const moduleSide = readModuleSide(moduleFile, checker);\n const specSide = readSpecSide(\n file(specPath),\n opened,\n modulePath,\n moduleFile.path,\n new Set(input.specSpecifiers ?? [\"eutaxy/spec\", \"@eutaxy/spec\"]),\n );\n errors.push(...moduleSide.errors, ...specSide.errors);\n // The spec file runs whenever it is imported (the TESTED rung imports it): an assignment to a\n // built-in there makes the claims compute something other than what they are read as.\n const patched = rebound(file(specPath), checker, opened.standardGlobal);\n if (patched)\n errors.push({\n line: patched.line,\n message: `the spec file assigns to ${patched.target}, so the built-ins its claims are read with may not be the standard ones`,\n });\n // The claims' free names: the spec file's local names for the module's declarations.\n const imports = specSide.imports.flatMap((i) => {\n const fn = moduleSide.exports.get(i.name);\n return fn === undefined ? [] : [{ local: i.local, fn }];\n });\n const byFunction = new Map<string, { decl: Declaration; properties: Property[] }>();\n for (const s of specSide.specs) {\n const local = moduleSide.exports.get(s.fn);\n const decl = local === undefined ? undefined : moduleSide.declarations.get(local);\n if (!decl) {\n errors.push({\n line: s.line,\n message: `${s.name}: the module exports no function ${s.fn} whose parameters the reader can read (a function declaration or a const arrow)`,\n });\n continue;\n }\n const entry = byFunction.get(s.fn) ?? { decl, properties: [] };\n if (entry.properties.some((p) => p.name === s.name)) {\n errors.push({ line: s.line, message: `${s.name} is exported twice` });\n continue;\n }\n const binders: Binder[] = decl.params.map((p, i) => {\n const fromEnsures = s.ensures?.params[i];\n const name = fromEnsures ?? p.name ?? `arg${i}`;\n const hint = s.hints.get(i);\n return { name, type: p.type, ...(hint ? { hint } : {}) };\n });\n entry.properties.push({\n name: s.name,\n kind: s.kind,\n binders,\n ...(s.sample ? { sample: s.sample } : {}),\n ...(s.when ? { when: s.when } : {}),\n ...(s.ensures ? { ensures: s.ensures } : {}),\n imports,\n text: s.text,\n line: s.line,\n });\n byFunction.set(s.fn, entry);\n }\n const functions: FunctionSpec[] = [...byFunction.entries()].map(\n ([name, { decl, properties }]) => ({\n name,\n params: decl.params,\n properties,\n line: decl.line,\n offset: decl.offset,\n }),\n );\n return { functions, errors };\n },\n );\n}\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