Skip to content

Commit 9a7be4e

Browse files
committed
Format the 2.5.1 checker changes and drop em dashes from comments
1 parent 497d707 commit 9a7be4e

3 files changed

Lines changed: 18 additions & 11 deletions

File tree

packages/core/src/diagnose.test.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ describe("analyzeSource — undefined head (gated)", () => {
8585
describe("analyzeSource — overloaded arity", () => {
8686
// The stdlib declares @param and @return twice: a one-string informal form and a longer formal form.
8787
// check_if_function_type_is_applicable accepts a call when ANY declared function type applies, so the
88-
// informal one-argument doc atomsused everywhere, including the stdlib itself are well-formed.
88+
// informal one-argument doc atoms, used everywhere, including the stdlib itself, are well-formed.
8989
it("accepts the one-argument @return doc form", () => {
9090
expect(analyzeSource('(@return "a result")', cfg)).toEqual([]);
9191
});
@@ -122,7 +122,7 @@ describe("analyzeSource — unevaluated (data) positions", () => {
122122
});
123123

124124
it("does not flag a wrong-arity term inside an if branch (an Atom-typed, unevaluated slot)", () => {
125-
// if : (-> Bool Atom Atom $t) — the branches are Atom-typed, so the interpreter never pre-evaluates them.
125+
// if : (-> Bool Atom Atom $t). Its branches are Atom-typed, so the interpreter never pre-evaluates them.
126126
const src = "(= (pick $c) (if $c (forall True) (forall False)))";
127127
expect(analyzeSource(src, cfg).filter((d) => d.code === "arity-mismatch")).toEqual([]);
128128
});
@@ -138,13 +138,15 @@ describe("analyzeSource — unevaluated (data) positions", () => {
138138
describe("analyzeSource — imported declarations", () => {
139139
it("treats an imported op's Atom-typed parameter as a data position", () => {
140140
// `store`'s formal type (declared in an imported module) has an Atom-typed second parameter, so its
141-
// argument is passed unevaluated — a wrong-arity term carried there is data, as the interpreter treats it.
141+
// argument is passed unevaluated. A wrong-arity term carried there is data, as the interpreter treats it.
142142
const call = "!(store &s (Wrap (forall)))";
143143
// Without the import, `store` is an untyped head: its args evaluate, so the nested (forall) is checked.
144144
expect(analyzeSource(call, cfg).filter((d) => d.code === "arity-mismatch")).toHaveLength(1);
145-
// With the imported signature in scope, the Atom-typed slot makes the argument data no arity error.
145+
// With the imported signature in scope, the Atom-typed slot makes the argument data, so no arity error.
146146
const imported = atomsOf("(: store (-> SpaceType Atom %Undefined%))");
147-
expect(analyzeSource(call, cfg, imported).filter((d) => d.code === "arity-mismatch")).toEqual([]);
147+
expect(analyzeSource(call, cfg, imported).filter((d) => d.code === "arity-mismatch")).toEqual(
148+
[],
149+
);
148150
});
149151
});
150152

packages/core/src/diagnose.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function checkUnknownHead(
8181
}
8282

8383
/** The parameter counts of every arrow type declared for `name`. The stdlib declares some ops more than
84-
* once`@doc`, `@param`, and `@return` each have an informal and a formal form and Hyperon
84+
* once. `@doc`, `@param`, and `@return` each have an informal and a formal form, and Hyperon
8585
* `check_if_function_type_is_applicable` accepts a call when ANY function type applies, so the well-formed
8686
* argument counts are the union over every overload, not just `env.sigs`'s single kept signature. */
8787
function declaredArities(env: MinEnv, name: string): Set<number> {
@@ -107,7 +107,7 @@ function checkArity(src: string, node: SpannedNode, env: MinEnv, out: Diagnostic
107107
const name = headName(node);
108108
if (name === undefined) return;
109109
// An op that also carries a non-arrow (tuple/atom) type can legitimately appear as data, so an arity check
110-
// against its arrow signature is unsafe matches eval's `has_tuple_type` fallback.
110+
// against its arrow signature is unsafe. This matches eval's `has_tuple_type` fallback.
111111
if (hasTupleType(env, name)) return;
112112
const arities = declaredArities(env, name);
113113
if (arities.size === 0) return; // no declared function type: an unknown head is legal data, not an error
@@ -123,7 +123,7 @@ function checkArity(src: string, node: SpannedNode, env: MinEnv, out: Diagnostic
123123

124124
/** Parameter types the interpreter passes UNEVALUATED: `Atom` (spec `metta`: `$type == Atom` returns the
125125
* argument as-is) and the `Variable`/`Expression` meta-types a form binds or matches. A call sitting at
126-
* such a positiona case/if/let branch, a match/unify pattern, a quoted term is data the interpreter
126+
* such a position, a case/if/let branch, a match/unify pattern, or a quoted term, is data the interpreter
127127
* never applies, so it is never arity- or undefined-checked. Read straight from the ops' own signatures. */
128128
const UNEVALUATED_PARAM_TYPES = new Set(["Atom", "Variable", "Expression"]);
129129

@@ -156,7 +156,7 @@ function walk(
156156
): void {
157157
if (node.children === undefined) return;
158158
// A node in an unevaluated (data) position is never applied by the interpreter, so it carries no arity or
159-
// undefined-head error — the head is a pattern, constructor, or quoted symbol, not a function call.
159+
// undefined-head error. Its head is a pattern, constructor, or quoted symbol, not a function call.
160160
if (!inData) {
161161
checkArity(src, node, env, out);
162162
if (config.undefinedSymbols && matcher !== undefined) {
@@ -200,7 +200,7 @@ export function analyze(
200200

201201
/** Every declaration reachable through a resolved import graph, de-duplicated by module identity (the map
202202
* keys each module by both its import name and its canonical id). Feeding these to the analyzer's env lets
203-
* a call to a cross-file-typed opwhose `(: ...)` lives in an imported module be checked against the
203+
* a call to a cross-file-typed op, whose `(: ...)` lives in an imported module, be checked against the
204204
* same signature the runtime sees, instead of reading as an untyped head whose arguments all evaluate.
205205
* Mirrors the runtime's `import!` def extraction (eval `appendImportedModule`). */
206206
export function importedDefinitions(imports: ImportMap): Atom[] {

packages/node/src/check.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55
// plus an exit code. No process IO here, so it is unit-testable; cli.ts does the reading and exiting.
66
import { readFileSync } from "node:fs";
77
import { dirname, resolve } from "node:path";
8-
import { analyzeSource, importedDefinitions, renderAll, DiagnosticSeverity } from "@mettascript/core";
8+
import {
9+
analyzeSource,
10+
importedDefinitions,
11+
renderAll,
12+
DiagnosticSeverity,
13+
} from "@mettascript/core";
914
import { readImports } from "./file-imports";
1015

1116
export interface CheckOptions {

0 commit comments

Comments
 (0)