@intentius/chant 0.20.0 → 0.22.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/dist/build.d.ts +7 -0
- package/dist/build.d.ts.map +1 -1
- package/dist/cli/commands/build.d.ts.map +1 -1
- package/dist/cli/commands/check-lexicon-examples.d.ts.map +1 -1
- package/dist/cli/commands/check-lexicon-intrinsics.d.ts +17 -0
- package/dist/cli/commands/check-lexicon-intrinsics.d.ts.map +1 -1
- package/dist/cli/commands/check-lexicon.d.ts.map +1 -1
- package/dist/codegen/docs-types.d.ts +2 -0
- package/dist/codegen/docs-types.d.ts.map +1 -1
- package/dist/declarable.d.ts +16 -0
- package/dist/declarable.d.ts.map +1 -1
- package/dist/discovery/entity-wire-codec.d.ts.map +1 -1
- package/dist/discovery/fold-import.d.ts +64 -3
- package/dist/discovery/fold-import.d.ts.map +1 -1
- package/dist/discovery/index.d.ts +12 -0
- package/dist/discovery/index.d.ts.map +1 -1
- package/dist/fold/fold.d.ts +89 -16
- package/dist/fold/fold.d.ts.map +1 -1
- package/dist/fold/foldable-helpers.d.ts +121 -0
- package/dist/fold/foldable-helpers.d.ts.map +1 -0
- package/dist/fold/subset.d.ts +58 -3
- package/dist/fold/subset.d.ts.map +1 -1
- package/dist/lexicon-schema.d.ts +2 -0
- package/dist/lexicon-schema.d.ts.map +1 -1
- package/dist/lexicon.d.ts +73 -23
- package/dist/lexicon.d.ts.map +1 -1
- package/dist/runtime.d.ts +10 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/serializer-walker.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/build.ts +9 -0
- package/src/cli/commands/build.ts +9 -0
- package/src/cli/commands/check-lexicon-examples.ts +16 -1
- package/src/cli/commands/check-lexicon-intrinsics.test.ts +35 -1
- package/src/cli/commands/check-lexicon-intrinsics.ts +38 -2
- package/src/cli/commands/check-lexicon.ts +18 -0
- package/src/codegen/docs-sections.test.ts +7 -1
- package/src/codegen/docs-sections.ts +1 -1
- package/src/codegen/docs-types.ts +2 -0
- package/src/declarable.ts +20 -0
- package/src/discovery/entity-wire-codec.ts +9 -7
- package/src/discovery/fold-import.test.ts +900 -1
- package/src/discovery/fold-import.ts +441 -47
- package/src/discovery/index.ts +25 -1
- package/src/fold/fold.test.ts +277 -0
- package/src/fold/fold.ts +219 -58
- package/src/fold/foldable-helpers.ts +171 -0
- package/src/fold/subset-doc-parity.test.ts +27 -0
- package/src/fold/subset.test.ts +177 -0
- package/src/fold/subset.ts +139 -31
- package/src/lexicon-schema.test.ts +43 -0
- package/src/lexicon-schema.ts +5 -0
- package/src/lexicon.ts +74 -24
- package/src/runtime.ts +11 -2
- package/src/serializer-walker.ts +14 -0
package/dist/fold/subset.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as ts from "typescript";
|
|
2
|
+
import { type IntrinsicDef } from "../lexicon.js";
|
|
2
3
|
/**
|
|
3
4
|
* subset — the single canonical definition of chant's statically-foldable
|
|
4
5
|
* expression subset (chant #1024, epic #1019).
|
|
@@ -36,6 +37,38 @@ import * as ts from "typescript";
|
|
|
36
37
|
* manifest, which isn't available to a syntax-only lint rule. `fold()`
|
|
37
38
|
* alone checks it; this module treats any tag name as shape-valid and
|
|
38
39
|
* only classifies the interpolated values.
|
|
40
|
+
* 2b. Authoring-helper *provenance* (chant #1082) — a call to a registered
|
|
41
|
+
* chant helper (`phase(...)`, `output(...)`; ./foldable-helpers.ts)
|
|
42
|
+
* folds, but only when the name is genuinely bound to an import of
|
|
43
|
+
* chant's own. That needs the module graph, which a syntax-only lint
|
|
44
|
+
* rule doesn't have. This module checks the NAME only and stays
|
|
45
|
+
* permissive; `fold()`'s bridge does the provenance check and falls the
|
|
46
|
+
* file back to run when it fails. Same direction as every other item
|
|
47
|
+
* here — a false negative for EVL, never a false positive.
|
|
48
|
+
* 2c. Intrinsic *call-form* registration (chant #1044) — a plain call to a
|
|
49
|
+
* lexicon intrinsic the lexicon opted in (`Ref(bucket)`,
|
|
50
|
+
* `Concat(a, b)`; `IntrinsicDef.foldsAsCall`, ../lexicon.ts) folds.
|
|
51
|
+
* Whether a given name is such an intrinsic is not knowable from shape,
|
|
52
|
+
* so {@link findSubsetViolation} takes the registry as an OPTIONAL
|
|
53
|
+
* parameter instead of guessing: supply it and the answer for a call is
|
|
54
|
+
* exact (fold()'s own), omit it and every call is a violation, the
|
|
55
|
+
* pre-#1044 answer.
|
|
56
|
+
*
|
|
57
|
+
* That parameter is the whole reason the call case lives here rather
|
|
58
|
+
* than only in `fold()`. This module is a shared predicate, and the
|
|
59
|
+
* point of a shared predicate is that a consumer can ask "will this
|
|
60
|
+
* fold?" without running fold — a control plane deciding whether a
|
|
61
|
+
* repository needs a sandboxed child process at all, for instance.
|
|
62
|
+
* Keeping the case out of here would make the predicate answer "no" for
|
|
63
|
+
* idiomatic `Ref(...)` source that `fold()` reduces cleanly: not a
|
|
64
|
+
* permissive gap but a systematically WRONG answer in the expensive
|
|
65
|
+
* direction, and the one direction this module is not allowed to be
|
|
66
|
+
* wrong in (see the false-negative/false-positive rule in point 1, and
|
|
67
|
+
* the flow-sensitivity note below — the single divergence in the other
|
|
68
|
+
* direction, and the one this module treats as a wart). A caller with
|
|
69
|
+
* no registry degrades to "assume it runs", which is safe and cheap to
|
|
70
|
+
* reason about; EVL is exactly such a caller and its behavior on calls
|
|
71
|
+
* is unchanged by #1044.
|
|
39
72
|
* 3. Runtime *type* of a folded value — e.g. spreading `const n = 5`
|
|
40
73
|
* (`{...n}`) is shape-valid (`n` is a plain identifier) but `fold()`
|
|
41
74
|
* rejects it once it discovers `n` folds to a number, not an object.
|
|
@@ -72,14 +105,36 @@ export declare const SUPPORTED_UNARY_OPERATORS: ReadonlySet<ts.SyntaxKind>;
|
|
|
72
105
|
export declare function isLiteralPropertyName(node: ts.PropertyName): node is ts.Identifier | ts.StringLiteral | ts.NumericLiteral;
|
|
73
106
|
/** An element-access key foldable without execution: a string or numeric LITERAL only (EVL003 semantics). */
|
|
74
107
|
export declare function isLiteralElementKey(node: ts.Expression): node is ts.StringLiteral | ts.NumericLiteral;
|
|
108
|
+
/**
|
|
109
|
+
* A short, single-line rendering of `node`'s source text for embedding in a
|
|
110
|
+
* diagnostic message — never the raw `getText()`, which reproduces the
|
|
111
|
+
* node's ENTIRE source verbatim and can span dozens of lines for a real
|
|
112
|
+
* composite call or object literal (chant #1054: a fold fallback reason that
|
|
113
|
+
* embeds one of these buries the actual error after it, and breaks any
|
|
114
|
+
* line-oriented consumer of `[fold:run]` output). Internal whitespace
|
|
115
|
+
* (including newlines) collapses to a single space, and the result is capped
|
|
116
|
+
* to a bounded length so one pathological node can't blow out an otherwise
|
|
117
|
+
* one-line reason either.
|
|
118
|
+
*/
|
|
119
|
+
export declare function briefNodeText(node: ts.Node, maxLength?: number): string;
|
|
75
120
|
export declare function computedPropertyNameMessage(node: ts.PropertyName): string;
|
|
76
121
|
export declare function dynamicElementAccessMessage(keyNode: ts.Expression): string;
|
|
77
122
|
export declare const UNSUPPORTED_OBJECT_MEMBER_MESSAGE = "unsupported object member";
|
|
78
123
|
export declare const UNSUPPORTED_UNARY_MESSAGE = "unsupported unary";
|
|
79
124
|
export declare function unsupportedBinaryMessage(opKind: ts.SyntaxKind): string;
|
|
125
|
+
/**
|
|
126
|
+
* chant #1054 — the ONE wording for "a bare function/method call used where
|
|
127
|
+
* chant needs a value it can fold." Before this, `fold()` (this message) and
|
|
128
|
+
* `../discovery/fold-import.ts`'s `resolveCallExpression` (a top-level
|
|
129
|
+
* export's own call-as-a-value check) had each grown their own hand-written
|
|
130
|
+
* copy — "function call as a value" here, "call expression as a value"
|
|
131
|
+
* there — for the identical rejection, which meant a tool grouping fallback
|
|
132
|
+
* reasons by text had to match both to avoid silently under-counting one of
|
|
133
|
+
* them. `resolveCallExpression` now calls this function directly instead of
|
|
134
|
+
* building its own string.
|
|
135
|
+
*/
|
|
80
136
|
export declare function callExpressionMessage(node: ts.CallExpression): string;
|
|
81
137
|
export declare function unsupportedExpressionMessage(node: ts.Node): string;
|
|
82
|
-
export declare function resourceCtorArgMessage(typeName: string): string;
|
|
83
138
|
/**
|
|
84
139
|
* Classify one object-literal member (`{ a: 1 }`'s `a: 1`, `{ ...x }`'s
|
|
85
140
|
* `...x`, or a shorthand `{ a }`). Checks the key's shape before the
|
|
@@ -87,7 +142,7 @@ export declare function resourceCtorArgMessage(typeName: string): string;
|
|
|
87
142
|
* the value. Returns the first violation within this member, or
|
|
88
143
|
* `undefined` when it's fully in the subset.
|
|
89
144
|
*/
|
|
90
|
-
export declare function checkObjectMember(prop: ts.ObjectLiteralElementLike): SubsetViolation | undefined;
|
|
145
|
+
export declare function checkObjectMember(prop: ts.ObjectLiteralElementLike, intrinsics?: readonly IntrinsicDef[]): SubsetViolation | undefined;
|
|
91
146
|
/**
|
|
92
147
|
* The canonical recursive shape classifier: is `node`'s expression *shape*
|
|
93
148
|
* within the subset `fold()` can reduce? Mirrors `fold()`'s own dispatch
|
|
@@ -98,5 +153,5 @@ export declare function checkObjectMember(prop: ts.ObjectLiteralElementLike): Su
|
|
|
98
153
|
* `fold()`-evaluation-order) unsupported node, or `undefined` when `node`'s
|
|
99
154
|
* whole shape is foldable.
|
|
100
155
|
*/
|
|
101
|
-
export declare function findSubsetViolation(node: ts.Node): SubsetViolation | undefined;
|
|
156
|
+
export declare function findSubsetViolation(node: ts.Node, intrinsics?: readonly IntrinsicDef[]): SubsetViolation | undefined;
|
|
102
157
|
//# sourceMappingURL=subset.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subset.d.ts","sourceRoot":"","sources":["../../src/fold/subset.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC
|
|
1
|
+
{"version":3,"file":"subset.d.ts","sourceRoot":"","sources":["../../src/fold/subset.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,OAAO,EAAsB,KAAK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AC,MAAM,EAAE,EAAE,CAAC,UAAU,GAAG,MAAM,CAEtE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,EAAE,CAAC,cAAc,GAAG,MAAM,CAErE;AAED,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,MAAM,CAElE;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,EAAE,CAAC,wBAAwB,EACjC,UAAU,CAAC,EAAE,SAAS,YAAY,EAAE,GACnC,eAAe,GAAG,SAAS,CAc7B;AAWD;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,EAAE,CAAC,IAAI,EACb,UAAU,CAAC,EAAE,SAAS,YAAY,EAAE,GACnC,eAAe,GAAG,SAAS,CAiK7B"}
|
package/dist/lexicon-schema.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export declare const IntrinsicDefSchema: z.ZodObject<{
|
|
|
8
8
|
description: z.ZodOptional<z.ZodString>;
|
|
9
9
|
outputKey: z.ZodOptional<z.ZodString>;
|
|
10
10
|
isTag: z.ZodBoolean;
|
|
11
|
+
foldsAsCall: z.ZodOptional<z.ZodBoolean>;
|
|
11
12
|
}, z.core.$strip>;
|
|
12
13
|
export declare const LexiconManifestSchema: z.ZodObject<{
|
|
13
14
|
name: z.ZodString;
|
|
@@ -19,6 +20,7 @@ export declare const LexiconManifestSchema: z.ZodObject<{
|
|
|
19
20
|
description: z.ZodOptional<z.ZodString>;
|
|
20
21
|
outputKey: z.ZodOptional<z.ZodString>;
|
|
21
22
|
isTag: z.ZodBoolean;
|
|
23
|
+
foldsAsCall: z.ZodOptional<z.ZodBoolean>;
|
|
22
24
|
}, z.core.$strip>>>;
|
|
23
25
|
pseudoParameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
24
26
|
}, z.core.$strip>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lexicon-schema.d.ts","sourceRoot":"","sources":["../src/lexicon-schema.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,eAAe,EAAgB,MAAM,WAAW,CAAC;AAM/D,eAAO,MAAM,kBAAkB
|
|
1
|
+
{"version":3,"file":"lexicon-schema.d.ts","sourceRoot":"","sources":["../src/lexicon-schema.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,eAAe,EAAgB,MAAM,WAAW,CAAC;AAM/D,eAAO,MAAM,kBAAkB;;;;;;iBAY7B,CAAC;AAQH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;iBAOhC,CAAC;AAiCH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAmB7B,CAAC;AAMH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAMpE;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,eAAe,CA2B/D;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAmBjF"}
|
package/dist/lexicon.d.ts
CHANGED
|
@@ -142,36 +142,86 @@ export interface IntrinsicDef {
|
|
|
142
142
|
* `../cli/commands/check-lexicon-intrinsics.ts`.
|
|
143
143
|
*/
|
|
144
144
|
readonly isTag: boolean;
|
|
145
|
+
/**
|
|
146
|
+
* chant #1044 — opt this intrinsic's PLAIN-CALL form into folding
|
|
147
|
+
* (`Ref(bucket)`, `Concat(a, b)` reduce to their intrinsic node instead of
|
|
148
|
+
* falling the whole file back to the run path).
|
|
149
|
+
*
|
|
150
|
+
* Optional, and OFF unless a lexicon writes `true`. That default is the
|
|
151
|
+
* point: `fold()` has no general `CallExpression` case by construction
|
|
152
|
+
* (epic #1019), and this field is the only thing that admits one. It is a
|
|
153
|
+
* closed, lexicon-declared allowlist, decided one intrinsic at a time —
|
|
154
|
+
* never inferred from `isTag`, from the name, or from the call's shape. An
|
|
155
|
+
* intrinsic with no `foldsAsCall` behaves exactly as it did before #1044.
|
|
156
|
+
*
|
|
157
|
+
* Only set it when calling the intrinsic is a pure function of its
|
|
158
|
+
* arguments that builds a deterministic data envelope — the whole
|
|
159
|
+
* correctness argument is that invoking it while folding is
|
|
160
|
+
* indistinguishable from invoking it during a real run of the file. An
|
|
161
|
+
* intrinsic that reads the environment, mutates state, or depends on
|
|
162
|
+
* anything but its arguments does not qualify, and neither does a tagged
|
|
163
|
+
* template (see {@link isTag}: the two forms are mutually exclusive, and
|
|
164
|
+
* `chant dev check-lexicon` rejects `isTag: true` + `foldsAsCall: true`).
|
|
165
|
+
*
|
|
166
|
+
* Registration is by name. It is not permission to invoke whatever that
|
|
167
|
+
* name happens to be bound to: `fold()` reduces the call to a symbolic
|
|
168
|
+
* envelope executing nothing, and `../discovery/fold-import.ts` resolves
|
|
169
|
+
* the name through the folding FILE'S OWN imports before invoking the real
|
|
170
|
+
* function — so the function that runs while folding is the same one the
|
|
171
|
+
* run path would have called, from the module the source itself named.
|
|
172
|
+
*/
|
|
173
|
+
readonly foldsAsCall?: boolean;
|
|
145
174
|
}
|
|
146
175
|
/**
|
|
147
|
-
* Whether `chant build --fold` can ever fold a
|
|
148
|
-
* (chant #1062, epic #1019)
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
* a
|
|
153
|
-
*
|
|
176
|
+
* Whether `chant build --fold` can ever fold a use of this intrinsic
|
|
177
|
+
* (chant #1062, epic #1019) — in EITHER authored form.
|
|
178
|
+
*
|
|
179
|
+
* Two disjoint ways to qualify, one per form:
|
|
180
|
+
*
|
|
181
|
+
* - a registered tagged-template intrinsic (`Sub\`...\``) folds because
|
|
182
|
+
* `foldTaggedTemplate` recognizes its tag and recurses into the interior
|
|
183
|
+
* ({@link intrinsicTagFolds});
|
|
184
|
+
* - a registered plain-call intrinsic (`Ref(...)`, `Concat(...)`) folds
|
|
185
|
+
* only when its lexicon opted it in with `foldsAsCall`
|
|
186
|
+
* ({@link intrinsicCallFolds}, chant #1044). Before #1044 no plain call
|
|
187
|
+
* folded at all, whatever it was named or registered as.
|
|
154
188
|
*
|
|
155
|
-
* This function is the single predicate
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
* foldable; every caller keeps working unchanged, and the generated matrix
|
|
162
|
-
* updates the moment a lexicon's registration says a given intrinsic now
|
|
163
|
-
* folds — no doc rewrite, no second code path to remember.
|
|
189
|
+
* This function is the single predicate the generated per-lexicon intrinsics
|
|
190
|
+
* page (`../codegen/docs-sections.ts`'s "Folds?" column) calls — never a
|
|
191
|
+
* restated copy that could silently drift from the code. `fold()` itself
|
|
192
|
+
* calls the two form-specific predicates below rather than this one, because
|
|
193
|
+
* it always knows which form it is looking at, and a tag must not fold as a
|
|
194
|
+
* call (or vice versa) merely because the other form was opted in.
|
|
164
195
|
*
|
|
165
|
-
* Takes `{ isTag
|
|
166
|
-
* deliberately: `IntrinsicDef.isTag` is required
|
|
167
|
-
* (chant #1067), but
|
|
168
|
-
* possibly-older parsed JSON (`ManifestJSON` in
|
|
169
|
-
* on disk as a published lexicon's
|
|
170
|
-
*
|
|
171
|
-
* did — not a tag
|
|
196
|
+
* Takes a structural `{ isTag?, foldsAsCall? }` rather than
|
|
197
|
+
* `Pick<IntrinsicDef, ...>` deliberately: `IntrinsicDef.isTag` is required
|
|
198
|
+
* for new registrations (chant #1067), but these predicates also read off
|
|
199
|
+
* untrusted, possibly-older parsed JSON (`ManifestJSON` in
|
|
200
|
+
* `./codegen/docs-types.ts`, on disk as a published lexicon's
|
|
201
|
+
* `dist/manifest.json`) that may predate either field. `undefined` there
|
|
202
|
+
* means what it always did — not a tag, not opted in.
|
|
172
203
|
*/
|
|
173
204
|
export declare function intrinsicFolds(def: {
|
|
174
205
|
isTag?: boolean;
|
|
206
|
+
foldsAsCall?: boolean;
|
|
207
|
+
}): boolean;
|
|
208
|
+
/** True when this intrinsic's TAGGED-TEMPLATE form folds (`Sub\`...\``) — see {@link intrinsicFolds}. */
|
|
209
|
+
export declare function intrinsicTagFolds(def: {
|
|
210
|
+
isTag?: boolean;
|
|
211
|
+
}): boolean;
|
|
212
|
+
/**
|
|
213
|
+
* True when this intrinsic's PLAIN-CALL form folds (`Ref(...)`) — i.e. the
|
|
214
|
+
* lexicon opted it in via {@link IntrinsicDef.foldsAsCall} (chant #1044).
|
|
215
|
+
*
|
|
216
|
+
* `isTag: true` disqualifies regardless: a tagged template is invoked as
|
|
217
|
+
* `` Name`...` ``, so a call to it isn't the registered authoring form at
|
|
218
|
+
* all. Keeping that here rather than trusting registrations means a lexicon
|
|
219
|
+
* that declares both flags cannot quietly widen `fold()`'s call case — and
|
|
220
|
+
* `chant dev check-lexicon` fails the registration outright.
|
|
221
|
+
*/
|
|
222
|
+
export declare function intrinsicCallFolds(def: {
|
|
223
|
+
isTag?: boolean;
|
|
224
|
+
foldsAsCall?: boolean;
|
|
175
225
|
}): boolean;
|
|
176
226
|
/**
|
|
177
227
|
* Options passed to a MigrationSource by `chant migrate`.
|
package/dist/lexicon.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lexicon.d.ts","sourceRoot":"","sources":["../src/lexicon.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,C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,UAAU,CAAC,EAAE,aAAa,CAAC;CACrC,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAC;IACb,iEAAiE;IACjE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sCAAsC;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,mCAAmC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uCAAuC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACjC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;IAC/B,4DAA4D;IAC5D,IAAI,EAAE,MAAM,CAAC;IACb,6BAA6B;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sCAAsC;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,mCAAmC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mCAAmC;IACnC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAkBtE"}
|
package/dist/runtime.d.ts
CHANGED
|
@@ -18,6 +18,15 @@ import { type Declarable } from "./declarable.js";
|
|
|
18
18
|
export declare function createResource(type: string, lexicon: string, attrMap: Record<string, string>): new (props: Record<string, unknown>, attributes?: Record<string, unknown>) => Declarable & Record<string, string>;
|
|
19
19
|
/**
|
|
20
20
|
* Create a property-kind class for a given property type.
|
|
21
|
+
*
|
|
22
|
+
* Instances carry DECLARABLE_MARKER/lexicon/entityType/kind at runtime (set
|
|
23
|
+
* via defineProperty below), so they already satisfy `Declarable` — the
|
|
24
|
+
* return type just needs to say so. Before this, the signature was
|
|
25
|
+
* `Record<string, unknown>` with no `Declarable`, so any composite that
|
|
26
|
+
* returned a property-kind instance as a top-level member only type-checked
|
|
27
|
+
* by accident: either the caller went through an untyped `require()` (losing
|
|
28
|
+
* the type entirely) or never assigned the instance where its `Declarable`-ness
|
|
29
|
+
* was checked statically. See chant #1068.
|
|
21
30
|
*/
|
|
22
|
-
export declare function createProperty(type: string, lexicon: string): new (props: Record<string, unknown>) => Record<string, unknown>;
|
|
31
|
+
export declare function createProperty(type: string, lexicon: string): new (props: Record<string, unknown>) => Declarable & Record<string, unknown>;
|
|
23
32
|
//# sourceMappingURL=runtime.d.ts.map
|
package/dist/runtime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAqB,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAGlE;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,KAAK,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA4BnH;AAED
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAqB,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAGlE;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,KAAK,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA4BnH;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,KAAK,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAY9E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializer-walker.d.ts","sourceRoot":"","sources":["../src/serializer-walker.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAM/C,MAAM,WAAW,iBAAiB;IAChC,4DAA4D;IAC5D,OAAO,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;IACzD,mEAAmE;IACnE,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC;IAC1C,+DAA+D;IAC/D,kBAAkB,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,OAAO,GAAG,OAAO,CAAC;CAChF;AAED;;;GAGG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,OAAO,EACd,WAAW,EAAE,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,EACpC,OAAO,EAAE,iBAAiB,GACzB,OAAO,
|
|
1
|
+
{"version":3,"file":"serializer-walker.d.ts","sourceRoot":"","sources":["../src/serializer-walker.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAM/C,MAAM,WAAW,iBAAiB;IAChC,4DAA4D;IAC5D,OAAO,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;IACzD,mEAAmE;IACnE,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC;IAC1C,+DAA+D;IAC/D,kBAAkB,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,OAAO,GAAG,OAAO,CAAC;CAChF;AAED;;;GAGG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,OAAO,EACd,WAAW,EAAE,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,EACpC,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAuET"}
|
package/package.json
CHANGED
package/src/build.ts
CHANGED
|
@@ -170,6 +170,14 @@ export interface BuildOptions {
|
|
|
170
170
|
*/
|
|
171
171
|
intrinsics?: IntrinsicDef[];
|
|
172
172
|
|
|
173
|
+
/**
|
|
174
|
+
* chant #1063 — the lexicon names loaded for this build. Passed straight
|
|
175
|
+
* through to {@link DiscoveryOptions.lexicons} in `./discovery/index`;
|
|
176
|
+
* ignored unless {@link fold} is set. The CLI populates this from
|
|
177
|
+
* `options.plugins.map(p => p.name)`.
|
|
178
|
+
*/
|
|
179
|
+
lexicons?: readonly string[];
|
|
180
|
+
|
|
173
181
|
/**
|
|
174
182
|
* chant #1045 Phase 2 — opt-in: run-fallback files (or, when {@link fold}
|
|
175
183
|
* isn't set, every file) execute together, isolated, in one sandboxed
|
|
@@ -513,6 +521,7 @@ export async function build(
|
|
|
513
521
|
const discoveryResult = await discover(path, {
|
|
514
522
|
fold: options?.fold,
|
|
515
523
|
intrinsics: options?.intrinsics,
|
|
524
|
+
lexicons: options?.lexicons,
|
|
516
525
|
sandbox: options?.sandbox,
|
|
517
526
|
buildParams: options?.buildParams,
|
|
518
527
|
});
|
|
@@ -201,6 +201,14 @@ export async function buildCommand(options: BuildOptions): Promise<BuildResult>
|
|
|
201
201
|
// any), hence the guard.
|
|
202
202
|
const intrinsics = options.plugins?.flatMap((plugin) => plugin.intrinsics?.() ?? []) ?? [];
|
|
203
203
|
|
|
204
|
+
// #1063 — the same loaded plugins, by NAME, are this build's allowlist for
|
|
205
|
+
// following a bare import specifier into a lexicon package (so `Azure`,
|
|
206
|
+
// `GCP`, `S3Actions`, `CI` fold as values). A plugin's `name` is the
|
|
207
|
+
// lexicon name `loadPlugin()` was called with, which is exactly what
|
|
208
|
+
// `@intentius/chant-lexicon-<name>` was imported from — see
|
|
209
|
+
// ../plugins.ts and fold-import.ts's `lexiconPackageName`.
|
|
210
|
+
const lexicons = options.plugins?.map((plugin) => plugin.name) ?? [];
|
|
211
|
+
|
|
204
212
|
// Run the build
|
|
205
213
|
const result = await build(infraPath, options.serializers, undefined, {
|
|
206
214
|
ownership,
|
|
@@ -208,6 +216,7 @@ export async function buildCommand(options: BuildOptions): Promise<BuildResult>
|
|
|
208
216
|
fold,
|
|
209
217
|
sandbox,
|
|
210
218
|
intrinsics,
|
|
219
|
+
lexicons,
|
|
211
220
|
buildParams: paramsResolution.provenance,
|
|
212
221
|
});
|
|
213
222
|
|
|
@@ -32,6 +32,7 @@ import { join } from "path";
|
|
|
32
32
|
import { build } from "../../build";
|
|
33
33
|
import { findInfraFiles } from "../../discovery/files";
|
|
34
34
|
import { detectLexicons } from "../../detectLexicon";
|
|
35
|
+
import { loadChantConfig } from "../../config";
|
|
35
36
|
import { loadPlugins } from "../plugins";
|
|
36
37
|
|
|
37
38
|
export interface ExampleBuildResult {
|
|
@@ -64,7 +65,21 @@ export async function checkExamplesBuild(lexiconDir: string): Promise<ExampleBui
|
|
|
64
65
|
const files = await findInfraFiles(srcDir);
|
|
65
66
|
if (files.length === 0) continue;
|
|
66
67
|
|
|
67
|
-
|
|
68
|
+
// An example's own chant.config.{ts,json} (living beside src/, not in
|
|
69
|
+
// it) can declare `lexicons` explicitly — the same precedence real
|
|
70
|
+
// `chant build` gives it via resolveProjectLexicons() in ../plugins.ts.
|
|
71
|
+
// Needed for examples like helm's HelmRender ones, whose composite
|
|
72
|
+
// legitimately produces entities tagged with a lexicon (e.g. "k8s")
|
|
73
|
+
// that no source-file import mentions — detection from imports alone
|
|
74
|
+
// can never see it, so the example built with only its "own" lexicon's
|
|
75
|
+
// plugin and silently dropped every entity of the other, undetectable
|
|
76
|
+
// one. Detection from source-file imports (unchanged) remains the
|
|
77
|
+
// fallback for the many examples with no declared `lexicons` list.
|
|
78
|
+
const { config: exampleConfig } = await loadChantConfig(join(examplesDir, entry.name));
|
|
79
|
+
const lexiconNames =
|
|
80
|
+
exampleConfig.lexicons && exampleConfig.lexicons.length > 0
|
|
81
|
+
? exampleConfig.lexicons
|
|
82
|
+
: await detectLexicons(files);
|
|
68
83
|
if (lexiconNames.length === 0) {
|
|
69
84
|
results.push({
|
|
70
85
|
example: entry.name,
|
|
@@ -28,6 +28,8 @@ function writeFixture(dir: string): void {
|
|
|
28
28
|
{ name: "Mismatch1", description: "claims tag but is a plain call", isTag: true },
|
|
29
29
|
{ name: "Mismatch2", description: "claims plain but is a tagged template", isTag: false },
|
|
30
30
|
{ name: "Missing1", description: "registered but never exported", isTag: false },
|
|
31
|
+
{ name: "Plain2", description: "a plain call opted into call-form folding", isTag: false, foldsAsCall: true },
|
|
32
|
+
{ name: "Tag2", description: "a tagged template wrongly opted into call-form folding", isTag: true, foldsAsCall: true },
|
|
31
33
|
];
|
|
32
34
|
},
|
|
33
35
|
};
|
|
@@ -36,7 +38,7 @@ function writeFixture(dir: string): void {
|
|
|
36
38
|
|
|
37
39
|
writeFileSync(
|
|
38
40
|
join(dir, "src/index.ts"),
|
|
39
|
-
`export { Tag1, Plain1, Mismatch1, Mismatch2 } from "./intrinsics";
|
|
41
|
+
`export { Tag1, Plain1, Mismatch1, Mismatch2, Plain2, Tag2 } from "./intrinsics";
|
|
40
42
|
`,
|
|
41
43
|
);
|
|
42
44
|
|
|
@@ -61,6 +63,16 @@ export function Mismatch1(x: string): string {
|
|
|
61
63
|
export function Mismatch2(strings: TemplateStringsArray, ...values: unknown[]): string {
|
|
62
64
|
return strings.join("");
|
|
63
65
|
}
|
|
66
|
+
|
|
67
|
+
export function Plain2(x: string): string {
|
|
68
|
+
return x;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// chant #1044 — registered with foldsAsCall: true above, but authored as a
|
|
72
|
+
// tagged template, so there is no plain-call form to opt in.
|
|
73
|
+
export function Tag2(strings: TemplateStringsArray, ...values: unknown[]): string {
|
|
74
|
+
return strings.join("");
|
|
75
|
+
}
|
|
64
76
|
`,
|
|
65
77
|
);
|
|
66
78
|
}
|
|
@@ -112,6 +124,28 @@ describe("auditIntrinsics", () => {
|
|
|
112
124
|
expect(item?.detail).toMatch(/not exported from src\/index\.ts/);
|
|
113
125
|
});
|
|
114
126
|
|
|
127
|
+
test("a plain call opted into call-form folding passes (chant #1044)", () => {
|
|
128
|
+
const items = auditIntrinsics(dir);
|
|
129
|
+
const item = items.find((i) => i.name === "Plain2");
|
|
130
|
+
expect(item).toMatchObject({ exported: true, actualIsTag: false, ok: true, declaredFoldsAsCall: true, callFormOk: true });
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
test("a tagged template registered with foldsAsCall: true fails — the opt-in is for plain calls only (chant #1044)", () => {
|
|
134
|
+
const items = auditIntrinsics(dir);
|
|
135
|
+
const item = items.find((i) => i.name === "Tag2");
|
|
136
|
+
// The isTag half is fine (it really is a tag); the call-form half is not.
|
|
137
|
+
expect(item?.ok).toBe(true);
|
|
138
|
+
expect(item?.callFormOk).toBe(false);
|
|
139
|
+
expect(item?.callFormDetail).toMatch(/authored as a tagged template.*foldsAsCall: true/);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
test("an intrinsic with no foldsAsCall at all is simply not opted in — absent, not false (chant #1044)", () => {
|
|
143
|
+
const items = auditIntrinsics(dir);
|
|
144
|
+
const item = items.find((i) => i.name === "Plain1");
|
|
145
|
+
expect(item?.declaredFoldsAsCall).toBeUndefined();
|
|
146
|
+
expect(item?.callFormOk).toBe(true);
|
|
147
|
+
});
|
|
148
|
+
|
|
115
149
|
test("returns [] for a lexicon with no intrinsics() method", () => {
|
|
116
150
|
const emptyDir = mkdtempSync(join(tmpdir(), "chant-check-lexicon-intrinsics-empty-"));
|
|
117
151
|
try {
|
|
@@ -24,6 +24,13 @@
|
|
|
24
24
|
* tag (see ../../fold/fold.ts). Anything else (a plain function, a class,
|
|
25
25
|
* a const object/proxy) cannot be invoked as `` Name`...` `` and must be
|
|
26
26
|
* `isTag: false`.
|
|
27
|
+
*
|
|
28
|
+
* chant #1044 adds a third question, for the same reason the first two
|
|
29
|
+
* exist: `foldsAsCall` opts an intrinsic's PLAIN-CALL form into folding, so
|
|
30
|
+
* declaring it on something authored as a tagged template claims a form that
|
|
31
|
+
* cannot be called that way. The two flags are mutually exclusive, and a
|
|
32
|
+
* registration setting both is a failure here rather than a silently ignored
|
|
33
|
+
* field.
|
|
27
34
|
*/
|
|
28
35
|
|
|
29
36
|
import { existsSync, readFileSync } from "fs";
|
|
@@ -36,6 +43,8 @@ export interface IntrinsicAuditItem {
|
|
|
36
43
|
name: string;
|
|
37
44
|
/** The `isTag` value as registered in `src/plugin.ts`'s `intrinsics()`. */
|
|
38
45
|
declaredIsTag: boolean | undefined;
|
|
46
|
+
/** The `foldsAsCall` opt-in as registered in `src/plugin.ts` (chant #1044); `undefined` when absent, which means "not opted in". */
|
|
47
|
+
declaredFoldsAsCall: boolean | undefined;
|
|
39
48
|
/** Whether `name` resolves to a real export of `src/index.ts`. */
|
|
40
49
|
exported: boolean;
|
|
41
50
|
/**
|
|
@@ -50,11 +59,20 @@ export interface IntrinsicAuditItem {
|
|
|
50
59
|
/** True only when exported AND the authored shape matches `declaredIsTag`. */
|
|
51
60
|
ok: boolean;
|
|
52
61
|
detail?: string;
|
|
62
|
+
/**
|
|
63
|
+
* chant #1044 — false only when `foldsAsCall: true` is registered on
|
|
64
|
+
* something authored as a tagged template. Tracked separately from
|
|
65
|
+
* {@link ok} so the two failures report as the two different registration
|
|
66
|
+
* mistakes they are, rather than one message covering both.
|
|
67
|
+
*/
|
|
68
|
+
callFormOk: boolean;
|
|
69
|
+
callFormDetail?: string;
|
|
53
70
|
}
|
|
54
71
|
|
|
55
72
|
interface DeclaredIntrinsic {
|
|
56
73
|
name: string;
|
|
57
74
|
isTag: boolean | undefined;
|
|
75
|
+
foldsAsCall: boolean | undefined;
|
|
58
76
|
}
|
|
59
77
|
|
|
60
78
|
interface ExportTarget {
|
|
@@ -80,7 +98,7 @@ function parseFile(path: string): ts.SourceFile | undefined {
|
|
|
80
98
|
/**
|
|
81
99
|
* Find `intrinsics(): IntrinsicDef[] { return [ ... ]; }` (or the arrow-
|
|
82
100
|
* function-property equivalent) in a plugin.ts source file and extract each
|
|
83
|
-
* registered `{ name, isTag }`
|
|
101
|
+
* registered `{ name, isTag, foldsAsCall }` triple from the array literal. Returns
|
|
84
102
|
* `undefined` when no `intrinsics` method exists at all (lexicons with no
|
|
85
103
|
* intrinsics, e.g. gcp/k8s, still return `[]` — that's a real empty array,
|
|
86
104
|
* not `undefined`).
|
|
@@ -127,6 +145,7 @@ function extractDeclaredIntrinsics(pluginPath: string): DeclaredIntrinsic[] | un
|
|
|
127
145
|
if (!ts.isObjectLiteralExpression(el)) continue;
|
|
128
146
|
let name: string | undefined;
|
|
129
147
|
let isTag: boolean | undefined;
|
|
148
|
+
let foldsAsCall: boolean | undefined;
|
|
130
149
|
|
|
131
150
|
for (const prop of el.properties) {
|
|
132
151
|
if (!ts.isPropertyAssignment(prop) || !ts.isIdentifier(prop.name)) continue;
|
|
@@ -136,10 +155,13 @@ function extractDeclaredIntrinsics(pluginPath: string): DeclaredIntrinsic[] | un
|
|
|
136
155
|
} else if (key === "isTag") {
|
|
137
156
|
if (prop.initializer.kind === ts.SyntaxKind.TrueKeyword) isTag = true;
|
|
138
157
|
else if (prop.initializer.kind === ts.SyntaxKind.FalseKeyword) isTag = false;
|
|
158
|
+
} else if (key === "foldsAsCall") {
|
|
159
|
+
if (prop.initializer.kind === ts.SyntaxKind.TrueKeyword) foldsAsCall = true;
|
|
160
|
+
else if (prop.initializer.kind === ts.SyntaxKind.FalseKeyword) foldsAsCall = false;
|
|
139
161
|
}
|
|
140
162
|
}
|
|
141
163
|
|
|
142
|
-
if (name !== undefined) result.push({ name, isTag });
|
|
164
|
+
if (name !== undefined) result.push({ name, isTag, foldsAsCall });
|
|
143
165
|
}
|
|
144
166
|
|
|
145
167
|
return result;
|
|
@@ -271,10 +293,12 @@ export function auditIntrinsics(lexiconDir: string): IntrinsicAuditItem[] {
|
|
|
271
293
|
items.push({
|
|
272
294
|
name: d.name,
|
|
273
295
|
declaredIsTag: d.isTag,
|
|
296
|
+
declaredFoldsAsCall: d.foldsAsCall,
|
|
274
297
|
exported: false,
|
|
275
298
|
actualIsTag: undefined,
|
|
276
299
|
ok: false,
|
|
277
300
|
detail: `"${d.name}" is registered in plugin.ts intrinsics() but is not exported from src/index.ts`,
|
|
301
|
+
callFormOk: true,
|
|
278
302
|
});
|
|
279
303
|
continue;
|
|
280
304
|
}
|
|
@@ -284,22 +308,34 @@ export function auditIntrinsics(lexiconDir: string): IntrinsicAuditItem[] {
|
|
|
284
308
|
items.push({
|
|
285
309
|
name: d.name,
|
|
286
310
|
declaredIsTag: d.isTag,
|
|
311
|
+
declaredFoldsAsCall: d.foldsAsCall,
|
|
287
312
|
exported: true,
|
|
288
313
|
actualIsTag: undefined,
|
|
289
314
|
ok: false,
|
|
290
315
|
detail: `could not locate the declaration of "${d.name}" (exported from ${target.modulePath}) to verify it against isTag`,
|
|
316
|
+
callFormOk: true,
|
|
291
317
|
});
|
|
292
318
|
continue;
|
|
293
319
|
}
|
|
294
320
|
|
|
295
321
|
const declaredTag = d.isTag === true;
|
|
296
322
|
const ok = resolved.isTag === declaredTag;
|
|
323
|
+
// chant #1044 — `foldsAsCall` opts the PLAIN-CALL form in, so it is
|
|
324
|
+
// meaningless (and, if honored, wrong) on a tagged template. Judged
|
|
325
|
+
// against how the export is really authored, not against the sibling
|
|
326
|
+
// `isTag` claim, which may itself be the thing that's wrong.
|
|
327
|
+
const callFormOk = !(d.foldsAsCall === true && resolved.isTag === true);
|
|
297
328
|
items.push({
|
|
298
329
|
name: d.name,
|
|
299
330
|
declaredIsTag: d.isTag,
|
|
331
|
+
declaredFoldsAsCall: d.foldsAsCall,
|
|
300
332
|
exported: true,
|
|
301
333
|
actualIsTag: resolved.isTag,
|
|
302
334
|
ok,
|
|
335
|
+
callFormOk,
|
|
336
|
+
callFormDetail: callFormOk
|
|
337
|
+
? undefined
|
|
338
|
+
: `"${d.name}" is authored as a tagged template but registered with foldsAsCall: true — the call-form opt-in applies to plain-call intrinsics only`,
|
|
303
339
|
detail: ok
|
|
304
340
|
? undefined
|
|
305
341
|
: resolved.isTag
|
|
@@ -243,6 +243,24 @@ export async function checkLexicon(dir: string): Promise<CheckResult> {
|
|
|
243
243
|
: undefined,
|
|
244
244
|
});
|
|
245
245
|
|
|
246
|
+
// chant #1044 — the call-form opt-in (`foldsAsCall`) admits a plain call
|
|
247
|
+
// into `fold()`, which has no general CallExpression case. Declaring it on
|
|
248
|
+
// a tagged template claims a form the intrinsic cannot be invoked in, so
|
|
249
|
+
// it fails here rather than being quietly ignored — the same reasoning as
|
|
250
|
+
// the isTag check above.
|
|
251
|
+
const badCallForm = intrinsicAudit.filter((i) => !i.callFormOk);
|
|
252
|
+
items.push({
|
|
253
|
+
name: "Registered intrinsics' foldsAsCall opt-in is only on plain calls",
|
|
254
|
+
tier: 1,
|
|
255
|
+
pass: badCallForm.length === 0,
|
|
256
|
+
detail:
|
|
257
|
+
badCallForm.length > 0
|
|
258
|
+
? badCallForm.map((i) => i.callFormDetail).join(" | ")
|
|
259
|
+
: intrinsicAudit.length > 0
|
|
260
|
+
? `${intrinsicAudit.length} intrinsic(s) checked`
|
|
261
|
+
: undefined,
|
|
262
|
+
});
|
|
263
|
+
|
|
246
264
|
const hasPluginTest = findFiles(join(dir, "src"), (n) => n === "plugin.test.ts").length > 0;
|
|
247
265
|
items.push({
|
|
248
266
|
name: "plugin.test.ts exists",
|