@telorun/templating 0.137.0 → 0.139.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 +13 -11
- package/dist/cel/analyze.d.ts +4 -1
- package/dist/cel/analyze.d.ts.map +1 -1
- package/dist/cel/analyze.js +22 -9
- package/dist/cel/verdict-codes.d.ts +1 -1
- package/dist/cel/verdict-codes.d.ts.map +1 -1
- package/dist/cel/verdict-codes.js +3 -0
- package/package.json +3 -3
- package/src/cel/analyze.ts +30 -12
- package/src/cel/verdict-codes.ts +3 -0
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="https://github.com/telorun/telo/raw/templating@0.
|
|
2
|
+
<img src="https://github.com/telorun/telo/raw/templating@0.139.0/assets/telo.svg" alt="Telo" width="120" />
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
<h1 align="center">Telo</h1>
|
|
@@ -57,7 +57,7 @@ Telo reads your YAML files, checks them, works out what depends on what, starts
|
|
|
57
57
|
|
|
58
58
|
## Example manifest
|
|
59
59
|
|
|
60
|
-
See [examples/](https://github.com/telorun/telo/tree/templating@0.
|
|
60
|
+
See [examples/](https://github.com/telorun/telo/tree/templating@0.139.0/examples/) for a list of working applications.
|
|
61
61
|
|
|
62
62
|
## Status
|
|
63
63
|
|
|
@@ -93,22 +93,24 @@ The architecture is inspired by Kubernetes-style manifests: declarative resource
|
|
|
93
93
|
|
|
94
94
|
## See more at
|
|
95
95
|
|
|
96
|
-
- [Telo Kernel](https://github.com/telorun/telo/blob/templating@0.
|
|
97
|
-
- [Telo SDK for module authors](https://github.com/telorun/telo/blob/templating@0.
|
|
98
|
-
- [Modules](https://github.com/telorun/telo/blob/templating@0.
|
|
96
|
+
- [Telo Kernel](https://github.com/telorun/telo/blob/templating@0.139.0/kernel/README.md)
|
|
97
|
+
- [Telo SDK for module authors](https://github.com/telorun/telo/blob/templating@0.139.0/sdk/README.md)
|
|
98
|
+
- [Modules](https://github.com/telorun/telo/blob/templating@0.139.0/modules/README.md)
|
|
99
99
|
|
|
100
100
|
## License
|
|
101
101
|
|
|
102
|
-
In plain terms: Telo is free to use, including commercially.
|
|
102
|
+
In plain terms: Telo is free to use, including commercially. The runtime, the command-line tool, the editor tooling, the modules, the SDK, the examples and the docs are MIT. The runners, Studio and the authoring agent, which make up Telo's hosted platform, are source-available: you can build, host and sell your own products with them, but you cannot offer them to others as a managed service without a commercial licence from CodeNet Sp. z o.o. (contact@codenet.pl). Details: [Licensing](https://telo.run/learn/licensing).
|
|
103
103
|
|
|
104
|
-
Two licenses, split by directory. Each MIT directory carries its own `LICENSE`; everything else falls under the root [LICENSE](https://github.com/telorun/telo/blob/templating@0.
|
|
104
|
+
Two licenses, split by directory. Each MIT directory carries its own `LICENSE`; everything else falls under the root [LICENSE](https://github.com/telorun/telo/blob/templating@0.139.0/LICENSE), the Sustainable Use License.
|
|
105
105
|
|
|
106
106
|
| MIT | Sustainable Use |
|
|
107
107
|
| --- | --- |
|
|
108
|
-
| `
|
|
109
|
-
| `
|
|
110
|
-
| `
|
|
111
|
-
| `
|
|
108
|
+
| `kernel/`, `analyzer/`, `cli/` — what loads, checks and runs a manifest | `packages/runner-core/`, `apps/docker-runner/`, `apps/k8s-runner/`, `apps/host-runner/` — the runners |
|
|
109
|
+
| `packages/ide-support/`, `packages/language-server/`, `packages/language-host/`, `ide/vscode/` — the editor tooling | `apps/studio/`, `apps/authoring-agent/`, `pages/` and everything not listed |
|
|
110
|
+
| `packages/debug-wire/`, `packages/debug-ui/` — the debug wire format and the debug UI | |
|
|
111
|
+
| `cel/`, `message-format/`, `sdk/`, `templating/`, `release/`, `packages/glob/`, `packages/osv/`, `packages/editor-protocol/`, `packages/runner-protocol/`, `packages/share-tunnel/`, `packages/secret-seed/` — the expression engine, the message core, the SDK, the release planner, what a controller links against, the OSV advisory lookup, the runner `/v1` contract, the share tunnel and the secret seed | |
|
|
112
|
+
| `modules/`, `blueprints/` — the standard library | |
|
|
113
|
+
| `starters/`, `examples/`, `docs/`, `benchmarks/`, `apps/hub/`, `apps/hub-web/` | |
|
|
112
114
|
|
|
113
115
|
No MIT package depends on a Sustainable Use one, which `pnpm run check:licenses` enforces.
|
|
114
116
|
|
package/dist/cel/analyze.d.ts
CHANGED
|
@@ -49,8 +49,11 @@ export declare const ELEMENT_SEGMENT = "[]!";
|
|
|
49
49
|
* its elements: the chain ends in {@link EACH_SEGMENT}.
|
|
50
50
|
* - A bare use of the variable reads the element whole, so the range is read
|
|
51
51
|
* whole, as it is by any other use of the collection.
|
|
52
|
+
* - A `cel.bind` name is followed to the value it binds: `cel.bind(t,
|
|
53
|
+
* self.table, t.size)` reads `self.table.size`, and a bare use reads the
|
|
54
|
+
* bound value whole.
|
|
52
55
|
* - A presence test reads only whether the member exists: `has(a.b)` reads
|
|
53
|
-
* `a.?` ({@link PRESENCE_SEGMENT}), never the value of `a.b`.
|
|
56
|
+
* `a.b.?` ({@link PRESENCE_SEGMENT}), never the value of `a.b`.
|
|
54
57
|
*
|
|
55
58
|
* A variable whose range is not a plain chain (a call's result, another macro's
|
|
56
59
|
* output) names nothing a root holds, and a read through it contributes nothing.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyze.d.ts","sourceRoot":"","sources":["../../src/cel/analyze.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,OAAO,EACb,MAAM,cAAc,CAAC;AAItB;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,EAAE,EAAE,CAI7D;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,OAAO,GAAG,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,CAS5F;AA8FD;;+DAE+D;AAC/D,eAAO,MAAM,aAAa,QAAQ,CAAC;AA6BnC;qDACqD;AACrD,e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analyze.js
CHANGED
|
@@ -174,8 +174,11 @@ export const ELEMENT_SEGMENT = "[]!";
|
|
|
174
174
|
* its elements: the chain ends in {@link EACH_SEGMENT}.
|
|
175
175
|
* - A bare use of the variable reads the element whole, so the range is read
|
|
176
176
|
* whole, as it is by any other use of the collection.
|
|
177
|
+
* - A `cel.bind` name is followed to the value it binds: `cel.bind(t,
|
|
178
|
+
* self.table, t.size)` reads `self.table.size`, and a bare use reads the
|
|
179
|
+
* bound value whole.
|
|
177
180
|
* - A presence test reads only whether the member exists: `has(a.b)` reads
|
|
178
|
-
* `a.?` ({@link PRESENCE_SEGMENT}), never the value of `a.b`.
|
|
181
|
+
* `a.b.?` ({@link PRESENCE_SEGMENT}), never the value of `a.b`.
|
|
179
182
|
*
|
|
180
183
|
* A variable whose range is not a plain chain (a call's result, another macro's
|
|
181
184
|
* output) names nothing a root holds, and a read through it contributes nothing.
|
|
@@ -203,7 +206,10 @@ function readChainOf(node, bound) {
|
|
|
203
206
|
if (node.kind === "ident") {
|
|
204
207
|
if (!node.absolute && bound.has(node.name)) {
|
|
205
208
|
const range = bound.get(node.name);
|
|
206
|
-
|
|
209
|
+
if (!range)
|
|
210
|
+
return null;
|
|
211
|
+
range.used = true;
|
|
212
|
+
return range.each ? [...range.chain, EACH_SEGMENT] : [...range.chain];
|
|
207
213
|
}
|
|
208
214
|
return [node.name];
|
|
209
215
|
}
|
|
@@ -246,9 +252,9 @@ function visitReads(node, chains, bound, valueReads) {
|
|
|
246
252
|
}
|
|
247
253
|
const presence = presenceOperand(node);
|
|
248
254
|
if (presence) {
|
|
249
|
-
const owner = readChainOf(presence, bound);
|
|
255
|
+
const owner = readChainOf(presence.operand, bound);
|
|
250
256
|
if (owner !== null) {
|
|
251
|
-
chains.push([...owner, PRESENCE_SEGMENT]);
|
|
257
|
+
chains.push([...owner, presence.field, PRESENCE_SEGMENT]);
|
|
252
258
|
return;
|
|
253
259
|
}
|
|
254
260
|
}
|
|
@@ -260,8 +266,15 @@ function visitReads(node, chains, bound, valueReads) {
|
|
|
260
266
|
}
|
|
261
267
|
const bind = bindCall(node);
|
|
262
268
|
if (bind) {
|
|
263
|
-
|
|
264
|
-
|
|
269
|
+
// A plain chain is read through the name it binds, and whole where nothing
|
|
270
|
+
// reads through it: the value is still evaluated.
|
|
271
|
+
const value = readChainOf(bind.init, bound);
|
|
272
|
+
if (value === null)
|
|
273
|
+
visitReads(bind.init, chains, bound, valueReads);
|
|
274
|
+
const range = value && { chain: value, each: false, used: false };
|
|
275
|
+
visitReads(bind.body, chains, new Map(bound).set(bind.name, range), valueReads);
|
|
276
|
+
if (range && !range.used)
|
|
277
|
+
chains.push(value);
|
|
265
278
|
return;
|
|
266
279
|
}
|
|
267
280
|
const macro = comprehension(node);
|
|
@@ -271,7 +284,7 @@ function visitReads(node, chains, bound, valueReads) {
|
|
|
271
284
|
chains.push([...range, EACH_SEGMENT]);
|
|
272
285
|
else
|
|
273
286
|
visitReads(macro.receiver, chains, bound, valueReads);
|
|
274
|
-
const inner = new Map(bound).set(macro.bound, range);
|
|
287
|
+
const inner = new Map(bound).set(macro.bound, range && { chain: range, each: true, used: false });
|
|
275
288
|
for (const arg of macro.scoped)
|
|
276
289
|
visitReads(arg, chains, inner, valueReads);
|
|
277
290
|
return;
|
|
@@ -279,12 +292,12 @@ function visitReads(node, chains, bound, valueReads) {
|
|
|
279
292
|
for (const child of childNodes(node))
|
|
280
293
|
visitReads(child, chains, bound, valueReads);
|
|
281
294
|
}
|
|
282
|
-
/**
|
|
295
|
+
/** A presence test `has(<operand>.<field>)`: what it asks the keys of, and the member. */
|
|
283
296
|
function presenceOperand(node) {
|
|
284
297
|
if (node.kind !== "call" || node.name !== "has" || node.args.length !== 1)
|
|
285
298
|
return undefined;
|
|
286
299
|
const arg = node.args[0];
|
|
287
|
-
return arg.kind === "select" && !arg.optional ? arg.operand : undefined;
|
|
300
|
+
return arg.kind === "select" && !arg.optional ? { operand: arg.operand, field: arg.field } : undefined;
|
|
288
301
|
}
|
|
289
302
|
/**
|
|
290
303
|
* Every member access whose base is a module call, longest first — the chains
|
|
@@ -17,7 +17,7 @@ import type { CallAudit } from "./diagnose.js";
|
|
|
17
17
|
* nominal with a base and no parameters. Each is still reported where it IS decided — by
|
|
18
18
|
* the analyzer, against its own environment. */
|
|
19
19
|
export declare const CEL_VERDICT_CODES: {
|
|
20
|
-
readonly diagnostics: readonly ["BINDING_NAME_RESERVED", "CEL_INVALID_ARGUMENT", "CEL_NULLABLE_ACCESS", "CEL_SYNTAX_ERROR", "CEL_TYPE_ARGUMENT_MISMATCH", "CEL_TYPE_ERROR", "CEL_UNKNOWN_FIELD", "CEL_UNKNOWN_FUNCTION", "CEL_UNKNOWN_IDENTIFIER", "CEL_WRONG_CALL_FORM", "FUNCTION_ARGUMENT_MISMATCH", "FUNCTION_ARITY_MISMATCH", "FUNCTION_UNRESOLVED", "INTERPOLATION_HOLE_NOT_CONVERTIBLE"];
|
|
20
|
+
readonly diagnostics: readonly ["BINDING_NAME_RESERVED", "CEL_INVALID_ARGUMENT", "CEL_NULLABLE_ACCESS", "CEL_SYNTAX_ERROR", "CEL_TYPE_ARGUMENT_MISMATCH", "CEL_MISSING_FIELD", "CEL_TYPE_ERROR", "CEL_TYPE_NOT_CONSTRUCTIBLE", "CEL_UNKNOWN_FIELD", "CEL_UNKNOWN_FUNCTION", "CEL_UNKNOWN_IDENTIFIER", "CEL_UNKNOWN_TYPE", "CEL_WRONG_CALL_FORM", "FUNCTION_ARGUMENT_MISMATCH", "FUNCTION_ARITY_MISMATCH", "FUNCTION_UNRESOLVED", "INTERPOLATION_HOLE_NOT_CONVERTIBLE"];
|
|
21
21
|
readonly errors: readonly ["ERR_INTERPOLATION_HOLE_NOT_CONVERTIBLE"];
|
|
22
22
|
};
|
|
23
23
|
export type CelDiagnosticCode = (typeof CEL_VERDICT_CODES.diagnostics)[number];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verdict-codes.d.ts","sourceRoot":"","sources":["../../src/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Y,EAAE,OAAO,EAAE,MAAM,GAAG,YAAY,CAEjF"}
|
|
@@ -21,10 +21,13 @@ export const CEL_VERDICT_CODES = {
|
|
|
21
21
|
"CEL_NULLABLE_ACCESS",
|
|
22
22
|
"CEL_SYNTAX_ERROR",
|
|
23
23
|
"CEL_TYPE_ARGUMENT_MISMATCH",
|
|
24
|
+
"CEL_MISSING_FIELD",
|
|
24
25
|
"CEL_TYPE_ERROR",
|
|
26
|
+
"CEL_TYPE_NOT_CONSTRUCTIBLE",
|
|
25
27
|
"CEL_UNKNOWN_FIELD",
|
|
26
28
|
"CEL_UNKNOWN_FUNCTION",
|
|
27
29
|
"CEL_UNKNOWN_IDENTIFIER",
|
|
30
|
+
"CEL_UNKNOWN_TYPE",
|
|
28
31
|
"CEL_WRONG_CALL_FORM",
|
|
29
32
|
// Forwarded from the engine's checker, which decides them. Whether a module call
|
|
30
33
|
// REACHES a function, and whether its arity and arguments fit, is still the analyzer's
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telorun/templating",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.139.0",
|
|
4
4
|
"description": "Telo Templating - Engine registry and shared CEL core for Telo manifests.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"telo",
|
|
@@ -39,14 +39,14 @@
|
|
|
39
39
|
"re2js": "2.8.3",
|
|
40
40
|
"uuid": "14.0.1",
|
|
41
41
|
"yaml": "2.8.3",
|
|
42
|
-
"@telorun/cel": "0.
|
|
42
|
+
"@telorun/cel": "0.139.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/d3-format": "^3.0.4",
|
|
46
46
|
"@types/node": "^20.0.0",
|
|
47
47
|
"typescript": "^5.0.0",
|
|
48
48
|
"vitest": "^2.1.8",
|
|
49
|
-
"@telorun/sdk": "0.
|
|
49
|
+
"@telorun/sdk": "0.139.0"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"@telorun/sdk": "*"
|
package/src/cel/analyze.ts
CHANGED
|
@@ -195,8 +195,11 @@ export const ELEMENT_SEGMENT = "[]!";
|
|
|
195
195
|
* its elements: the chain ends in {@link EACH_SEGMENT}.
|
|
196
196
|
* - A bare use of the variable reads the element whole, so the range is read
|
|
197
197
|
* whole, as it is by any other use of the collection.
|
|
198
|
+
* - A `cel.bind` name is followed to the value it binds: `cel.bind(t,
|
|
199
|
+
* self.table, t.size)` reads `self.table.size`, and a bare use reads the
|
|
200
|
+
* bound value whole.
|
|
198
201
|
* - A presence test reads only whether the member exists: `has(a.b)` reads
|
|
199
|
-
* `a.?` ({@link PRESENCE_SEGMENT}), never the value of `a.b`.
|
|
202
|
+
* `a.b.?` ({@link PRESENCE_SEGMENT}), never the value of `a.b`.
|
|
200
203
|
*
|
|
201
204
|
* A variable whose range is not a plain chain (a call's result, another macro's
|
|
202
205
|
* output) names nothing a root holds, and a read through it contributes nothing.
|
|
@@ -222,14 +225,24 @@ export function extractValueReadChains(node: CelNode): string[][] {
|
|
|
222
225
|
return chains;
|
|
223
226
|
}
|
|
224
227
|
|
|
225
|
-
/**
|
|
226
|
-
|
|
228
|
+
/** What a bound name stands for as a chain — each element of a range, or the
|
|
229
|
+
* value a `cel.bind` binds — or null where it has none. */
|
|
230
|
+
type BoundRanges = ReadonlyMap<string, BoundRange | null>;
|
|
231
|
+
|
|
232
|
+
interface BoundRange {
|
|
233
|
+
readonly chain: readonly string[];
|
|
234
|
+
readonly each: boolean;
|
|
235
|
+
/** Whether anything read through the name. */
|
|
236
|
+
used: boolean;
|
|
237
|
+
}
|
|
227
238
|
|
|
228
239
|
function readChainOf(node: CelNode, bound: BoundRanges): string[] | null {
|
|
229
240
|
if (node.kind === "ident") {
|
|
230
241
|
if (!node.absolute && bound.has(node.name)) {
|
|
231
242
|
const range = bound.get(node.name);
|
|
232
|
-
|
|
243
|
+
if (!range) return null;
|
|
244
|
+
range.used = true;
|
|
245
|
+
return range.each ? [...range.chain, EACH_SEGMENT] : [...range.chain];
|
|
233
246
|
}
|
|
234
247
|
return [node.name];
|
|
235
248
|
}
|
|
@@ -270,9 +283,9 @@ function visitReads(node: CelNode, chains: string[][], bound: BoundRanges, value
|
|
|
270
283
|
|
|
271
284
|
const presence = presenceOperand(node);
|
|
272
285
|
if (presence) {
|
|
273
|
-
const owner = readChainOf(presence, bound);
|
|
286
|
+
const owner = readChainOf(presence.operand, bound);
|
|
274
287
|
if (owner !== null) {
|
|
275
|
-
chains.push([...owner, PRESENCE_SEGMENT]);
|
|
288
|
+
chains.push([...owner, presence.field, PRESENCE_SEGMENT]);
|
|
276
289
|
return;
|
|
277
290
|
}
|
|
278
291
|
}
|
|
@@ -285,8 +298,13 @@ function visitReads(node: CelNode, chains: string[][], bound: BoundRanges, value
|
|
|
285
298
|
|
|
286
299
|
const bind = bindCall(node);
|
|
287
300
|
if (bind) {
|
|
288
|
-
|
|
289
|
-
|
|
301
|
+
// A plain chain is read through the name it binds, and whole where nothing
|
|
302
|
+
// reads through it: the value is still evaluated.
|
|
303
|
+
const value = readChainOf(bind.init, bound);
|
|
304
|
+
if (value === null) visitReads(bind.init, chains, bound, valueReads);
|
|
305
|
+
const range: BoundRange | null = value && { chain: value, each: false, used: false };
|
|
306
|
+
visitReads(bind.body, chains, new Map(bound).set(bind.name, range), valueReads);
|
|
307
|
+
if (range && !range.used) chains.push(value!);
|
|
290
308
|
return;
|
|
291
309
|
}
|
|
292
310
|
|
|
@@ -295,7 +313,7 @@ function visitReads(node: CelNode, chains: string[][], bound: BoundRanges, value
|
|
|
295
313
|
const range = readChainOf(macro.receiver, bound);
|
|
296
314
|
if (range !== null) chains.push([...range, EACH_SEGMENT]);
|
|
297
315
|
else visitReads(macro.receiver, chains, bound, valueReads);
|
|
298
|
-
const inner = new Map(bound).set(macro.bound, range);
|
|
316
|
+
const inner = new Map(bound).set(macro.bound, range && { chain: range, each: true, used: false });
|
|
299
317
|
for (const arg of macro.scoped) visitReads(arg, chains, inner, valueReads);
|
|
300
318
|
return;
|
|
301
319
|
}
|
|
@@ -303,11 +321,11 @@ function visitReads(node: CelNode, chains: string[][], bound: BoundRanges, value
|
|
|
303
321
|
for (const child of childNodes(node)) visitReads(child, chains, bound, valueReads);
|
|
304
322
|
}
|
|
305
323
|
|
|
306
|
-
/**
|
|
307
|
-
function presenceOperand(node: CelNode): CelNode | undefined {
|
|
324
|
+
/** A presence test `has(<operand>.<field>)`: what it asks the keys of, and the member. */
|
|
325
|
+
function presenceOperand(node: CelNode): { operand: CelNode; field: string } | undefined {
|
|
308
326
|
if (node.kind !== "call" || node.name !== "has" || node.args.length !== 1) return undefined;
|
|
309
327
|
const arg = node.args[0]!;
|
|
310
|
-
return arg.kind === "select" && !arg.optional ? arg.operand : undefined;
|
|
328
|
+
return arg.kind === "select" && !arg.optional ? { operand: arg.operand, field: arg.field } : undefined;
|
|
311
329
|
}
|
|
312
330
|
|
|
313
331
|
/** A member access on a module call's result: the call, and the members read
|
package/src/cel/verdict-codes.ts
CHANGED
|
@@ -24,10 +24,13 @@ export const CEL_VERDICT_CODES = {
|
|
|
24
24
|
"CEL_NULLABLE_ACCESS",
|
|
25
25
|
"CEL_SYNTAX_ERROR",
|
|
26
26
|
"CEL_TYPE_ARGUMENT_MISMATCH",
|
|
27
|
+
"CEL_MISSING_FIELD",
|
|
27
28
|
"CEL_TYPE_ERROR",
|
|
29
|
+
"CEL_TYPE_NOT_CONSTRUCTIBLE",
|
|
28
30
|
"CEL_UNKNOWN_FIELD",
|
|
29
31
|
"CEL_UNKNOWN_FUNCTION",
|
|
30
32
|
"CEL_UNKNOWN_IDENTIFIER",
|
|
33
|
+
"CEL_UNKNOWN_TYPE",
|
|
31
34
|
"CEL_WRONG_CALL_FORM",
|
|
32
35
|
// Forwarded from the engine's checker, which decides them. Whether a module call
|
|
33
36
|
// REACHES a function, and whether its arity and arguments fit, is still the analyzer's
|