edict-lang 1.1.0 → 1.2.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/ast/nodes.d.ts +12 -3
- package/dist/ast/nodes.d.ts.map +1 -1
- package/dist/ast/nodes.js +1 -0
- package/dist/ast/nodes.js.map +1 -1
- package/dist/checker/check.js +9 -0
- package/dist/checker/check.js.map +1 -1
- package/dist/codegen/builtins.d.ts.map +1 -1
- package/dist/codegen/builtins.js +219 -0
- package/dist/codegen/builtins.js.map +1 -1
- package/dist/codegen/codegen.d.ts.map +1 -1
- package/dist/codegen/codegen.js +109 -18
- package/dist/codegen/codegen.js.map +1 -1
- package/dist/codegen/runner.d.ts.map +1 -1
- package/dist/codegen/runner.js +224 -15
- package/dist/codegen/runner.js.map +1 -1
- package/dist/errors/error-catalog.d.ts +33 -0
- package/dist/errors/error-catalog.d.ts.map +1 -0
- package/dist/errors/error-catalog.js +618 -0
- package/dist/errors/error-catalog.js.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp/create-server.d.ts.map +1 -1
- package/dist/mcp/create-server.js +54 -5
- package/dist/mcp/create-server.js.map +1 -1
- package/dist/mcp/handlers.d.ts +5 -1
- package/dist/mcp/handlers.d.ts.map +1 -1
- package/dist/mcp/handlers.js +17 -2
- package/dist/mcp/handlers.js.map +1 -1
- package/dist/mcp/minimal-schema.d.ts +8 -0
- package/dist/mcp/minimal-schema.d.ts.map +1 -0
- package/dist/mcp/minimal-schema.js +34 -0
- package/dist/mcp/minimal-schema.js.map +1 -0
- package/dist/resolver/resolve.js +4 -0
- package/dist/resolver/resolve.js.map +1 -1
- package/dist/validator/node-validators.d.ts.map +1 -1
- package/dist/validator/node-validators.js +12 -0
- package/dist/validator/node-validators.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,618 @@
|
|
|
1
|
+
// =============================================================================
|
|
2
|
+
// Error Catalog — Machine-readable catalog of all structured error types
|
|
3
|
+
// =============================================================================
|
|
4
|
+
// Auto-generated from the StructuredError union in structured-errors.ts.
|
|
5
|
+
// Agents can pre-learn every error type before encountering them, reducing
|
|
6
|
+
// discovery-by-failure round-trips.
|
|
7
|
+
/**
|
|
8
|
+
* Build the complete error catalog. This is a pure function with no dependencies
|
|
9
|
+
* on runtime state — the catalog is static and derived from type definitions.
|
|
10
|
+
*/
|
|
11
|
+
export function buildErrorCatalog() {
|
|
12
|
+
const errors = [
|
|
13
|
+
// =====================================================================
|
|
14
|
+
// Phase 1 — Validation errors
|
|
15
|
+
// =====================================================================
|
|
16
|
+
{
|
|
17
|
+
type: "duplicate_id",
|
|
18
|
+
pipeline_stage: "validator",
|
|
19
|
+
fields: [
|
|
20
|
+
{ name: "nodeId", type: "string" },
|
|
21
|
+
{ name: "firstPath", type: "string" },
|
|
22
|
+
{ name: "secondPath", type: "string" },
|
|
23
|
+
],
|
|
24
|
+
example_cause: {
|
|
25
|
+
kind: "module",
|
|
26
|
+
name: "test",
|
|
27
|
+
definitions: [
|
|
28
|
+
{ kind: "fn", id: "fn-main-001", name: "main", params: [], effects: ["io"], returnType: { kind: "basic", name: "Int" }, contracts: [], body: [{ kind: "literal", id: "lit-001", value: 1 }] },
|
|
29
|
+
{ kind: "fn", id: "fn-main-001", name: "helper", params: [], effects: ["pure"], returnType: { kind: "basic", name: "Int" }, contracts: [], body: [{ kind: "literal", id: "lit-002", value: 2 }] },
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
example_fix: {
|
|
33
|
+
kind: "module",
|
|
34
|
+
name: "test",
|
|
35
|
+
definitions: [
|
|
36
|
+
{ kind: "fn", id: "fn-main-001", name: "main", params: [], effects: ["io"], returnType: { kind: "basic", name: "Int" }, contracts: [], body: [{ kind: "literal", id: "lit-001", value: 1 }] },
|
|
37
|
+
{ kind: "fn", id: "fn-helper-001", name: "helper", params: [], effects: ["pure"], returnType: { kind: "basic", name: "Int" }, contracts: [], body: [{ kind: "literal", id: "lit-002", value: 2 }] },
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
type: "unknown_node_kind",
|
|
43
|
+
pipeline_stage: "validator",
|
|
44
|
+
fields: [
|
|
45
|
+
{ name: "path", type: "string" },
|
|
46
|
+
{ name: "received", type: "string" },
|
|
47
|
+
{ name: "validKinds", type: "string[]" },
|
|
48
|
+
],
|
|
49
|
+
example_cause: {
|
|
50
|
+
kind: "module",
|
|
51
|
+
name: "test",
|
|
52
|
+
definitions: [{ kind: "function", id: "fn-001", name: "main" }],
|
|
53
|
+
},
|
|
54
|
+
example_fix: {
|
|
55
|
+
kind: "module",
|
|
56
|
+
name: "test",
|
|
57
|
+
definitions: [{ kind: "fn", id: "fn-001", name: "main", params: [], effects: ["io"], returnType: { kind: "basic", name: "Int" }, contracts: [], body: [{ kind: "literal", id: "lit-001", value: 0 }] }],
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
type: "missing_field",
|
|
62
|
+
pipeline_stage: "validator",
|
|
63
|
+
fields: [
|
|
64
|
+
{ name: "path", type: "string" },
|
|
65
|
+
{ name: "nodeId", type: "string | null" },
|
|
66
|
+
{ name: "field", type: "string" },
|
|
67
|
+
{ name: "expectedFormat", type: "string" },
|
|
68
|
+
],
|
|
69
|
+
example_cause: {
|
|
70
|
+
kind: "module",
|
|
71
|
+
name: "test",
|
|
72
|
+
definitions: [{ kind: "fn", id: "fn-001", name: "main" }],
|
|
73
|
+
},
|
|
74
|
+
example_fix: {
|
|
75
|
+
kind: "module",
|
|
76
|
+
name: "test",
|
|
77
|
+
definitions: [{ kind: "fn", id: "fn-001", name: "main", params: [], effects: ["io"], returnType: { kind: "basic", name: "Int" }, contracts: [], body: [{ kind: "literal", id: "lit-001", value: 0 }] }],
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
type: "invalid_field_type",
|
|
82
|
+
pipeline_stage: "validator",
|
|
83
|
+
fields: [
|
|
84
|
+
{ name: "path", type: "string" },
|
|
85
|
+
{ name: "nodeId", type: "string | null" },
|
|
86
|
+
{ name: "field", type: "string" },
|
|
87
|
+
{ name: "expectedFormat", type: "string" },
|
|
88
|
+
{ name: "actualFormat", type: "string" },
|
|
89
|
+
],
|
|
90
|
+
example_cause: {
|
|
91
|
+
kind: "module",
|
|
92
|
+
name: "test",
|
|
93
|
+
definitions: [{ kind: "fn", id: "fn-001", name: 42, params: [], effects: ["io"], returnType: { kind: "basic", name: "Int" }, contracts: [], body: [] }],
|
|
94
|
+
},
|
|
95
|
+
example_fix: {
|
|
96
|
+
kind: "module",
|
|
97
|
+
name: "test",
|
|
98
|
+
definitions: [{ kind: "fn", id: "fn-001", name: "main", params: [], effects: ["io"], returnType: { kind: "basic", name: "Int" }, contracts: [], body: [{ kind: "literal", id: "lit-001", value: 0 }] }],
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
type: "invalid_effect",
|
|
103
|
+
pipeline_stage: "validator",
|
|
104
|
+
fields: [
|
|
105
|
+
{ name: "path", type: "string" },
|
|
106
|
+
{ name: "nodeId", type: "string | null" },
|
|
107
|
+
{ name: "received", type: "string" },
|
|
108
|
+
{ name: "validEffects", type: "string[]" },
|
|
109
|
+
],
|
|
110
|
+
example_cause: {
|
|
111
|
+
kind: "module",
|
|
112
|
+
name: "test",
|
|
113
|
+
definitions: [{ kind: "fn", id: "fn-001", name: "main", params: [], effects: ["network"], returnType: { kind: "basic", name: "Int" }, contracts: [], body: [{ kind: "literal", id: "lit-001", value: 0 }] }],
|
|
114
|
+
},
|
|
115
|
+
example_fix: {
|
|
116
|
+
kind: "module",
|
|
117
|
+
name: "test",
|
|
118
|
+
definitions: [{ kind: "fn", id: "fn-001", name: "main", params: [], effects: ["io"], returnType: { kind: "basic", name: "Int" }, contracts: [], body: [{ kind: "literal", id: "lit-001", value: 0 }] }],
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
type: "invalid_operator",
|
|
123
|
+
pipeline_stage: "validator",
|
|
124
|
+
fields: [
|
|
125
|
+
{ name: "path", type: "string" },
|
|
126
|
+
{ name: "nodeId", type: "string | null" },
|
|
127
|
+
{ name: "received", type: "string" },
|
|
128
|
+
{ name: "validOperators", type: "string[]" },
|
|
129
|
+
],
|
|
130
|
+
example_cause: {
|
|
131
|
+
kind: "module",
|
|
132
|
+
name: "test",
|
|
133
|
+
definitions: [{ kind: "fn", id: "fn-001", name: "main", params: [], effects: ["pure"], returnType: { kind: "basic", name: "Int" }, contracts: [], body: [{ kind: "binop", id: "binop-001", op: "**", left: { kind: "literal", id: "lit-001", value: 2 }, right: { kind: "literal", id: "lit-002", value: 3 } }] }],
|
|
134
|
+
},
|
|
135
|
+
example_fix: {
|
|
136
|
+
kind: "module",
|
|
137
|
+
name: "test",
|
|
138
|
+
definitions: [{ kind: "fn", id: "fn-001", name: "main", params: [], effects: ["pure"], returnType: { kind: "basic", name: "Int" }, contracts: [], body: [{ kind: "binop", id: "binop-001", op: "*", left: { kind: "literal", id: "lit-001", value: 2 }, right: { kind: "literal", id: "lit-002", value: 3 } }] }],
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
type: "invalid_basic_type_name",
|
|
143
|
+
pipeline_stage: "validator",
|
|
144
|
+
fields: [
|
|
145
|
+
{ name: "path", type: "string" },
|
|
146
|
+
{ name: "nodeId", type: "string | null" },
|
|
147
|
+
{ name: "received", type: "string" },
|
|
148
|
+
{ name: "validNames", type: "string[]" },
|
|
149
|
+
],
|
|
150
|
+
example_cause: {
|
|
151
|
+
kind: "module",
|
|
152
|
+
name: "test",
|
|
153
|
+
definitions: [{ kind: "fn", id: "fn-001", name: "main", params: [], effects: ["pure"], returnType: { kind: "basic", name: "Integer" }, contracts: [], body: [{ kind: "literal", id: "lit-001", value: 0 }] }],
|
|
154
|
+
},
|
|
155
|
+
example_fix: {
|
|
156
|
+
kind: "module",
|
|
157
|
+
name: "test",
|
|
158
|
+
definitions: [{ kind: "fn", id: "fn-001", name: "main", params: [], effects: ["pure"], returnType: { kind: "basic", name: "Int" }, contracts: [], body: [{ kind: "literal", id: "lit-001", value: 0 }] }],
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
type: "conflicting_effects",
|
|
163
|
+
pipeline_stage: "validator",
|
|
164
|
+
fields: [
|
|
165
|
+
{ name: "path", type: "string" },
|
|
166
|
+
{ name: "nodeId", type: "string | null" },
|
|
167
|
+
{ name: "effectsFound", type: "string[]" },
|
|
168
|
+
],
|
|
169
|
+
example_cause: {
|
|
170
|
+
kind: "module",
|
|
171
|
+
name: "test",
|
|
172
|
+
definitions: [{ kind: "fn", id: "fn-001", name: "main", params: [], effects: ["pure", "io"], returnType: { kind: "basic", name: "Int" }, contracts: [], body: [{ kind: "literal", id: "lit-001", value: 0 }] }],
|
|
173
|
+
},
|
|
174
|
+
example_fix: {
|
|
175
|
+
kind: "module",
|
|
176
|
+
name: "test",
|
|
177
|
+
definitions: [{ kind: "fn", id: "fn-001", name: "main", params: [], effects: ["io"], returnType: { kind: "basic", name: "Int" }, contracts: [], body: [{ kind: "literal", id: "lit-001", value: 0 }] }],
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
// =====================================================================
|
|
181
|
+
// Phase 2a — Name resolution errors
|
|
182
|
+
// =====================================================================
|
|
183
|
+
{
|
|
184
|
+
type: "undefined_reference",
|
|
185
|
+
pipeline_stage: "resolver",
|
|
186
|
+
fields: [
|
|
187
|
+
{ name: "nodeId", type: "string | null" },
|
|
188
|
+
{ name: "name", type: "string" },
|
|
189
|
+
{ name: "candidates", type: "string[]" },
|
|
190
|
+
{ name: "suggestion", type: "FixSuggestion?" },
|
|
191
|
+
],
|
|
192
|
+
example_cause: {
|
|
193
|
+
kind: "module",
|
|
194
|
+
name: "test",
|
|
195
|
+
definitions: [{ kind: "fn", id: "fn-001", name: "main", params: [], effects: ["pure"], returnType: { kind: "basic", name: "Int" }, contracts: [], body: [{ kind: "ident", id: "id-001", name: "undeclaredVar" }] }],
|
|
196
|
+
},
|
|
197
|
+
example_fix: {
|
|
198
|
+
kind: "module",
|
|
199
|
+
name: "test",
|
|
200
|
+
definitions: [{ kind: "fn", id: "fn-001", name: "main", params: [], effects: ["pure"], returnType: { kind: "basic", name: "Int" }, contracts: [], body: [{ kind: "literal", id: "lit-001", value: 42 }] }],
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
type: "duplicate_definition",
|
|
205
|
+
pipeline_stage: "resolver",
|
|
206
|
+
fields: [
|
|
207
|
+
{ name: "nodeId", type: "string | null" },
|
|
208
|
+
{ name: "name", type: "string" },
|
|
209
|
+
{ name: "firstNodeId", type: "string | null" },
|
|
210
|
+
],
|
|
211
|
+
example_cause: {
|
|
212
|
+
kind: "module",
|
|
213
|
+
name: "test",
|
|
214
|
+
definitions: [
|
|
215
|
+
{ kind: "fn", id: "fn-001", name: "main", params: [], effects: ["pure"], returnType: { kind: "basic", name: "Int" }, contracts: [], body: [{ kind: "literal", id: "lit-001", value: 1 }] },
|
|
216
|
+
{ kind: "fn", id: "fn-002", name: "main", params: [], effects: ["pure"], returnType: { kind: "basic", name: "Int" }, contracts: [], body: [{ kind: "literal", id: "lit-002", value: 2 }] },
|
|
217
|
+
],
|
|
218
|
+
},
|
|
219
|
+
example_fix: {
|
|
220
|
+
kind: "module",
|
|
221
|
+
name: "test",
|
|
222
|
+
definitions: [
|
|
223
|
+
{ kind: "fn", id: "fn-001", name: "main", params: [], effects: ["pure"], returnType: { kind: "basic", name: "Int" }, contracts: [], body: [{ kind: "literal", id: "lit-001", value: 1 }] },
|
|
224
|
+
{ kind: "fn", id: "fn-002", name: "helper", params: [], effects: ["pure"], returnType: { kind: "basic", name: "Int" }, contracts: [], body: [{ kind: "literal", id: "lit-002", value: 2 }] },
|
|
225
|
+
],
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
type: "unknown_record",
|
|
230
|
+
pipeline_stage: "resolver",
|
|
231
|
+
fields: [
|
|
232
|
+
{ name: "nodeId", type: "string | null" },
|
|
233
|
+
{ name: "name", type: "string" },
|
|
234
|
+
{ name: "candidates", type: "string[]" },
|
|
235
|
+
{ name: "suggestion", type: "FixSuggestion?" },
|
|
236
|
+
],
|
|
237
|
+
example_cause: {
|
|
238
|
+
kind: "module",
|
|
239
|
+
name: "test",
|
|
240
|
+
definitions: [{ kind: "fn", id: "fn-001", name: "main", params: [], effects: ["pure"], returnType: { kind: "basic", name: "Int" }, contracts: [], body: [{ kind: "record_literal", id: "rec-001", recordName: "NonExistent", fields: [] }] }],
|
|
241
|
+
},
|
|
242
|
+
example_fix: {
|
|
243
|
+
kind: "module",
|
|
244
|
+
name: "test",
|
|
245
|
+
definitions: [
|
|
246
|
+
{ kind: "record", id: "rec-def-001", name: "Point", fields: [{ name: "x", type: { kind: "basic", name: "Int" } }, { name: "y", type: { kind: "basic", name: "Int" } }] },
|
|
247
|
+
{ kind: "fn", id: "fn-001", name: "main", params: [], effects: ["pure"], returnType: { kind: "basic", name: "Int" }, contracts: [], body: [{ kind: "record_literal", id: "rec-001", recordName: "Point", fields: [{ name: "x", value: { kind: "literal", id: "lit-001", value: 0 } }, { name: "y", value: { kind: "literal", id: "lit-002", value: 0 } }] }] },
|
|
248
|
+
],
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
type: "unknown_enum",
|
|
253
|
+
pipeline_stage: "resolver",
|
|
254
|
+
fields: [
|
|
255
|
+
{ name: "nodeId", type: "string | null" },
|
|
256
|
+
{ name: "name", type: "string" },
|
|
257
|
+
{ name: "candidates", type: "string[]" },
|
|
258
|
+
{ name: "suggestion", type: "FixSuggestion?" },
|
|
259
|
+
],
|
|
260
|
+
example_cause: {
|
|
261
|
+
kind: "module",
|
|
262
|
+
name: "test",
|
|
263
|
+
definitions: [{ kind: "fn", id: "fn-001", name: "main", params: [], effects: ["pure"], returnType: { kind: "basic", name: "Int" }, contracts: [], body: [{ kind: "enum_literal", id: "en-001", enumName: "NonExistent", variant: "A", value: { kind: "literal", id: "lit-001", value: 1 } }] }],
|
|
264
|
+
},
|
|
265
|
+
example_fix: {
|
|
266
|
+
kind: "module",
|
|
267
|
+
name: "test",
|
|
268
|
+
definitions: [
|
|
269
|
+
{ kind: "enum", id: "enum-def-001", name: "Color", variants: [{ name: "Red", type: { kind: "basic", name: "Int" } }] },
|
|
270
|
+
{ kind: "fn", id: "fn-001", name: "main", params: [], effects: ["pure"], returnType: { kind: "basic", name: "Int" }, contracts: [], body: [{ kind: "enum_literal", id: "en-001", enumName: "Color", variant: "Red", value: { kind: "literal", id: "lit-001", value: 1 } }] },
|
|
271
|
+
],
|
|
272
|
+
},
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
type: "unknown_variant",
|
|
276
|
+
pipeline_stage: "resolver",
|
|
277
|
+
fields: [
|
|
278
|
+
{ name: "nodeId", type: "string | null" },
|
|
279
|
+
{ name: "enumName", type: "string" },
|
|
280
|
+
{ name: "variantName", type: "string" },
|
|
281
|
+
{ name: "availableVariants", type: "string[]" },
|
|
282
|
+
{ name: "suggestion", type: "FixSuggestion?" },
|
|
283
|
+
],
|
|
284
|
+
example_cause: {
|
|
285
|
+
kind: "module",
|
|
286
|
+
name: "test",
|
|
287
|
+
definitions: [
|
|
288
|
+
{ kind: "enum", id: "enum-001", name: "Color", variants: [{ name: "Red", type: { kind: "basic", name: "Int" } }] },
|
|
289
|
+
{ kind: "fn", id: "fn-001", name: "main", params: [], effects: ["pure"], returnType: { kind: "basic", name: "Int" }, contracts: [], body: [{ kind: "enum_literal", id: "en-001", enumName: "Color", variant: "Blue", value: { kind: "literal", id: "lit-001", value: 1 } }] },
|
|
290
|
+
],
|
|
291
|
+
},
|
|
292
|
+
example_fix: {
|
|
293
|
+
kind: "module",
|
|
294
|
+
name: "test",
|
|
295
|
+
definitions: [
|
|
296
|
+
{ kind: "enum", id: "enum-001", name: "Color", variants: [{ name: "Red", type: { kind: "basic", name: "Int" } }] },
|
|
297
|
+
{ kind: "fn", id: "fn-001", name: "main", params: [], effects: ["pure"], returnType: { kind: "basic", name: "Int" }, contracts: [], body: [{ kind: "enum_literal", id: "en-001", enumName: "Color", variant: "Red", value: { kind: "literal", id: "lit-001", value: 1 } }] },
|
|
298
|
+
],
|
|
299
|
+
},
|
|
300
|
+
},
|
|
301
|
+
// =====================================================================
|
|
302
|
+
// Phase 2b — Type checking errors
|
|
303
|
+
// =====================================================================
|
|
304
|
+
{
|
|
305
|
+
type: "type_mismatch",
|
|
306
|
+
pipeline_stage: "type_checker",
|
|
307
|
+
fields: [
|
|
308
|
+
{ name: "nodeId", type: "string | null" },
|
|
309
|
+
{ name: "expected", type: "TypeExpr" },
|
|
310
|
+
{ name: "actual", type: "TypeExpr" },
|
|
311
|
+
{ name: "suggestion", type: "FixSuggestion?" },
|
|
312
|
+
],
|
|
313
|
+
example_cause: {
|
|
314
|
+
kind: "module",
|
|
315
|
+
name: "test",
|
|
316
|
+
definitions: [{ kind: "fn", id: "fn-001", name: "main", params: [], effects: ["pure"], returnType: { kind: "basic", name: "Int" }, contracts: [], body: [{ kind: "literal", id: "lit-001", value: "hello" }] }],
|
|
317
|
+
},
|
|
318
|
+
example_fix: {
|
|
319
|
+
kind: "module",
|
|
320
|
+
name: "test",
|
|
321
|
+
definitions: [{ kind: "fn", id: "fn-001", name: "main", params: [], effects: ["pure"], returnType: { kind: "basic", name: "Int" }, contracts: [], body: [{ kind: "literal", id: "lit-001", value: 42 }] }],
|
|
322
|
+
},
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
type: "arity_mismatch",
|
|
326
|
+
pipeline_stage: "type_checker",
|
|
327
|
+
fields: [
|
|
328
|
+
{ name: "nodeId", type: "string | null" },
|
|
329
|
+
{ name: "expected", type: "number" },
|
|
330
|
+
{ name: "actual", type: "number" },
|
|
331
|
+
],
|
|
332
|
+
example_cause: {
|
|
333
|
+
kind: "module",
|
|
334
|
+
name: "test",
|
|
335
|
+
definitions: [
|
|
336
|
+
{ kind: "fn", id: "fn-001", name: "add", params: [{ id: "p-001", name: "a", type: { kind: "basic", name: "Int" } }, { id: "p-002", name: "b", type: { kind: "basic", name: "Int" } }], effects: ["pure"], returnType: { kind: "basic", name: "Int" }, contracts: [], body: [{ kind: "binop", id: "bin-001", op: "+", left: { kind: "ident", id: "id-001", name: "a" }, right: { kind: "ident", id: "id-002", name: "b" } }] },
|
|
337
|
+
{ kind: "fn", id: "fn-002", name: "main", params: [], effects: ["pure"], returnType: { kind: "basic", name: "Int" }, contracts: [], body: [{ kind: "call", id: "call-001", fn: "add", args: [{ kind: "literal", id: "lit-001", value: 1 }] }] },
|
|
338
|
+
],
|
|
339
|
+
},
|
|
340
|
+
example_fix: {
|
|
341
|
+
kind: "module",
|
|
342
|
+
name: "test",
|
|
343
|
+
definitions: [
|
|
344
|
+
{ kind: "fn", id: "fn-001", name: "add", params: [{ id: "p-001", name: "a", type: { kind: "basic", name: "Int" } }, { id: "p-002", name: "b", type: { kind: "basic", name: "Int" } }], effects: ["pure"], returnType: { kind: "basic", name: "Int" }, contracts: [], body: [{ kind: "binop", id: "bin-001", op: "+", left: { kind: "ident", id: "id-001", name: "a" }, right: { kind: "ident", id: "id-002", name: "b" } }] },
|
|
345
|
+
{ kind: "fn", id: "fn-002", name: "main", params: [], effects: ["pure"], returnType: { kind: "basic", name: "Int" }, contracts: [], body: [{ kind: "call", id: "call-001", fn: "add", args: [{ kind: "literal", id: "lit-001", value: 1 }, { kind: "literal", id: "lit-002", value: 2 }] }] },
|
|
346
|
+
],
|
|
347
|
+
},
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
type: "not_a_function",
|
|
351
|
+
pipeline_stage: "type_checker",
|
|
352
|
+
fields: [
|
|
353
|
+
{ name: "nodeId", type: "string | null" },
|
|
354
|
+
{ name: "actualType", type: "TypeExpr" },
|
|
355
|
+
],
|
|
356
|
+
example_cause: {
|
|
357
|
+
kind: "module",
|
|
358
|
+
name: "test",
|
|
359
|
+
definitions: [{ kind: "fn", id: "fn-001", name: "main", params: [], effects: ["pure"], returnType: { kind: "basic", name: "Int" }, contracts: [], body: [{ kind: "let", id: "let-001", name: "x", type: { kind: "basic", name: "Int" }, value: { kind: "literal", id: "lit-001", value: 5 }, body: { kind: "call", id: "call-001", fn: "x", args: [] } }] }],
|
|
360
|
+
},
|
|
361
|
+
example_fix: {
|
|
362
|
+
kind: "module",
|
|
363
|
+
name: "test",
|
|
364
|
+
definitions: [{ kind: "fn", id: "fn-001", name: "main", params: [], effects: ["pure"], returnType: { kind: "basic", name: "Int" }, contracts: [], body: [{ kind: "let", id: "let-001", name: "x", type: { kind: "basic", name: "Int" }, value: { kind: "literal", id: "lit-001", value: 5 }, body: { kind: "ident", id: "id-001", name: "x" } }] }],
|
|
365
|
+
},
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
type: "unknown_field",
|
|
369
|
+
pipeline_stage: "type_checker",
|
|
370
|
+
fields: [
|
|
371
|
+
{ name: "nodeId", type: "string | null" },
|
|
372
|
+
{ name: "recordName", type: "string" },
|
|
373
|
+
{ name: "fieldName", type: "string" },
|
|
374
|
+
{ name: "availableFields", type: "string[]" },
|
|
375
|
+
{ name: "suggestion", type: "FixSuggestion?" },
|
|
376
|
+
],
|
|
377
|
+
example_cause: {
|
|
378
|
+
kind: "module",
|
|
379
|
+
name: "test",
|
|
380
|
+
definitions: [
|
|
381
|
+
{ kind: "record", id: "rec-001", name: "Point", fields: [{ name: "x", type: { kind: "basic", name: "Int" } }, { name: "y", type: { kind: "basic", name: "Int" } }] },
|
|
382
|
+
{ kind: "fn", id: "fn-001", name: "main", params: [{ id: "p-001", name: "p", type: { kind: "basic", name: "Point" } }], effects: ["pure"], returnType: { kind: "basic", name: "Int" }, contracts: [], body: [{ kind: "access", id: "acc-001", target: { kind: "ident", id: "id-001", name: "p" }, field: "z" }] },
|
|
383
|
+
],
|
|
384
|
+
},
|
|
385
|
+
example_fix: {
|
|
386
|
+
kind: "module",
|
|
387
|
+
name: "test",
|
|
388
|
+
definitions: [
|
|
389
|
+
{ kind: "record", id: "rec-001", name: "Point", fields: [{ name: "x", type: { kind: "basic", name: "Int" } }, { name: "y", type: { kind: "basic", name: "Int" } }] },
|
|
390
|
+
{ kind: "fn", id: "fn-001", name: "main", params: [{ id: "p-001", name: "p", type: { kind: "basic", name: "Point" } }], effects: ["pure"], returnType: { kind: "basic", name: "Int" }, contracts: [], body: [{ kind: "access", id: "acc-001", target: { kind: "ident", id: "id-001", name: "p" }, field: "x" }] },
|
|
391
|
+
],
|
|
392
|
+
},
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
type: "missing_record_fields",
|
|
396
|
+
pipeline_stage: "type_checker",
|
|
397
|
+
fields: [
|
|
398
|
+
{ name: "nodeId", type: "string | null" },
|
|
399
|
+
{ name: "recordName", type: "string" },
|
|
400
|
+
{ name: "missingFields", type: "string[]" },
|
|
401
|
+
{ name: "suggestion", type: "FixSuggestion?" },
|
|
402
|
+
],
|
|
403
|
+
example_cause: {
|
|
404
|
+
kind: "module",
|
|
405
|
+
name: "test",
|
|
406
|
+
definitions: [
|
|
407
|
+
{ kind: "record", id: "rec-001", name: "Point", fields: [{ name: "x", type: { kind: "basic", name: "Int" } }, { name: "y", type: { kind: "basic", name: "Int" } }] },
|
|
408
|
+
{ kind: "fn", id: "fn-001", name: "main", params: [], effects: ["pure"], returnType: { kind: "basic", name: "Int" }, contracts: [], body: [{ kind: "record_literal", id: "rl-001", recordName: "Point", fields: [{ name: "x", value: { kind: "literal", id: "lit-001", value: 1 } }] }] },
|
|
409
|
+
],
|
|
410
|
+
},
|
|
411
|
+
example_fix: {
|
|
412
|
+
kind: "module",
|
|
413
|
+
name: "test",
|
|
414
|
+
definitions: [
|
|
415
|
+
{ kind: "record", id: "rec-001", name: "Point", fields: [{ name: "x", type: { kind: "basic", name: "Int" } }, { name: "y", type: { kind: "basic", name: "Int" } }] },
|
|
416
|
+
{ kind: "fn", id: "fn-001", name: "main", params: [], effects: ["pure"], returnType: { kind: "basic", name: "Int" }, contracts: [], body: [{ kind: "record_literal", id: "rl-001", recordName: "Point", fields: [{ name: "x", value: { kind: "literal", id: "lit-001", value: 1 } }, { name: "y", value: { kind: "literal", id: "lit-002", value: 2 } }] }] },
|
|
417
|
+
],
|
|
418
|
+
},
|
|
419
|
+
},
|
|
420
|
+
// =====================================================================
|
|
421
|
+
// Phase 3 — Effect checking errors
|
|
422
|
+
// =====================================================================
|
|
423
|
+
{
|
|
424
|
+
type: "effect_violation",
|
|
425
|
+
pipeline_stage: "effect_checker",
|
|
426
|
+
fields: [
|
|
427
|
+
{ name: "nodeId", type: "string | null" },
|
|
428
|
+
{ name: "functionName", type: "string" },
|
|
429
|
+
{ name: "missingEffects", type: "Effect[]" },
|
|
430
|
+
{ name: "callSiteNodeId", type: "string | null" },
|
|
431
|
+
{ name: "calleeName", type: "string" },
|
|
432
|
+
{ name: "suggestion", type: "FixSuggestion?" },
|
|
433
|
+
],
|
|
434
|
+
example_cause: {
|
|
435
|
+
kind: "module",
|
|
436
|
+
name: "test",
|
|
437
|
+
definitions: [
|
|
438
|
+
{ kind: "fn", id: "fn-001", name: "greet", params: [], effects: ["reads"], returnType: { kind: "basic", name: "String" }, contracts: [], body: [{ kind: "call", id: "call-001", fn: "print", args: [{ kind: "literal", id: "lit-001", value: "hi" }] }] },
|
|
439
|
+
],
|
|
440
|
+
},
|
|
441
|
+
example_fix: {
|
|
442
|
+
kind: "module",
|
|
443
|
+
name: "test",
|
|
444
|
+
definitions: [
|
|
445
|
+
{ kind: "fn", id: "fn-001", name: "greet", params: [], effects: ["io"], returnType: { kind: "basic", name: "String" }, contracts: [], body: [{ kind: "call", id: "call-001", fn: "print", args: [{ kind: "literal", id: "lit-001", value: "hi" }] }] },
|
|
446
|
+
],
|
|
447
|
+
},
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
type: "effect_in_pure",
|
|
451
|
+
pipeline_stage: "effect_checker",
|
|
452
|
+
fields: [
|
|
453
|
+
{ name: "nodeId", type: "string | null" },
|
|
454
|
+
{ name: "functionName", type: "string" },
|
|
455
|
+
{ name: "callSiteNodeId", type: "string | null" },
|
|
456
|
+
{ name: "calleeName", type: "string" },
|
|
457
|
+
{ name: "calleeEffects", type: "Effect[]" },
|
|
458
|
+
{ name: "suggestion", type: "FixSuggestion?" },
|
|
459
|
+
],
|
|
460
|
+
example_cause: {
|
|
461
|
+
kind: "module",
|
|
462
|
+
name: "test",
|
|
463
|
+
definitions: [
|
|
464
|
+
{ kind: "fn", id: "fn-001", name: "greet", params: [], effects: ["pure"], returnType: { kind: "basic", name: "String" }, contracts: [], body: [{ kind: "call", id: "call-001", fn: "print", args: [{ kind: "literal", id: "lit-001", value: "hi" }] }] },
|
|
465
|
+
],
|
|
466
|
+
},
|
|
467
|
+
example_fix: {
|
|
468
|
+
kind: "module",
|
|
469
|
+
name: "test",
|
|
470
|
+
definitions: [
|
|
471
|
+
{ kind: "fn", id: "fn-001", name: "greet", params: [], effects: ["io"], returnType: { kind: "basic", name: "String" }, contracts: [], body: [{ kind: "call", id: "call-001", fn: "print", args: [{ kind: "literal", id: "lit-001", value: "hi" }] }] },
|
|
472
|
+
],
|
|
473
|
+
},
|
|
474
|
+
},
|
|
475
|
+
// =====================================================================
|
|
476
|
+
// Phase 4 — Contract verification errors
|
|
477
|
+
// =====================================================================
|
|
478
|
+
{
|
|
479
|
+
type: "contract_failure",
|
|
480
|
+
pipeline_stage: "contract_verifier",
|
|
481
|
+
fields: [
|
|
482
|
+
{ name: "nodeId", type: "string" },
|
|
483
|
+
{ name: "contractId", type: "string" },
|
|
484
|
+
{ name: "functionName", type: "string" },
|
|
485
|
+
{ name: "contractKind", type: "\"pre\" | \"post\"" },
|
|
486
|
+
{ name: "counterexample", type: "Record<string, unknown>" },
|
|
487
|
+
],
|
|
488
|
+
example_cause: {
|
|
489
|
+
kind: "module",
|
|
490
|
+
name: "test",
|
|
491
|
+
definitions: [{ kind: "fn", id: "fn-001", name: "abs", params: [{ id: "p-001", name: "x", type: { kind: "basic", name: "Int" } }], effects: ["pure"], returnType: { kind: "basic", name: "Int" }, contracts: [{ kind: "post", id: "post-001", condition: { kind: "binop", id: "cmp-001", op: ">", left: { kind: "ident", id: "id-r", name: "result" }, right: { kind: "literal", id: "lit-z", value: 0 } } }], body: [{ kind: "ident", id: "id-001", name: "x" }] }],
|
|
492
|
+
},
|
|
493
|
+
example_fix: {
|
|
494
|
+
kind: "module",
|
|
495
|
+
name: "test",
|
|
496
|
+
definitions: [{ kind: "fn", id: "fn-001", name: "abs", params: [{ id: "p-001", name: "x", type: { kind: "basic", name: "Int" } }], effects: ["pure"], returnType: { kind: "basic", name: "Int" }, contracts: [{ kind: "post", id: "post-001", condition: { kind: "binop", id: "cmp-001", op: ">=", left: { kind: "ident", id: "id-r", name: "result" }, right: { kind: "literal", id: "lit-z", value: 0 } } }], body: [{ kind: "if", id: "if-001", condition: { kind: "binop", id: "cmp-002", op: ">=", left: { kind: "ident", id: "id-x1", name: "x" }, right: { kind: "literal", id: "lit-001", value: 0 } }, then: { kind: "ident", id: "id-x2", name: "x" }, else: { kind: "binop", id: "neg-001", op: "*", left: { kind: "literal", id: "lit-m1", value: -1 }, right: { kind: "ident", id: "id-x3", name: "x" } } }] }],
|
|
497
|
+
},
|
|
498
|
+
},
|
|
499
|
+
{
|
|
500
|
+
type: "verification_timeout",
|
|
501
|
+
pipeline_stage: "contract_verifier",
|
|
502
|
+
fields: [
|
|
503
|
+
{ name: "nodeId", type: "string" },
|
|
504
|
+
{ name: "contractId", type: "string" },
|
|
505
|
+
{ name: "functionName", type: "string" },
|
|
506
|
+
{ name: "timeoutMs", type: "number" },
|
|
507
|
+
],
|
|
508
|
+
example_cause: {
|
|
509
|
+
kind: "module",
|
|
510
|
+
name: "test",
|
|
511
|
+
definitions: [{ kind: "fn", id: "fn-001", name: "complex", params: [{ id: "p-001", name: "x", type: { kind: "basic", name: "Int" } }], effects: ["pure"], returnType: { kind: "basic", name: "Int" }, contracts: [{ kind: "post", id: "post-001", condition: { kind: "literal", id: "lit-t", value: true } }], body: [{ kind: "ident", id: "id-001", name: "x" }] }],
|
|
512
|
+
},
|
|
513
|
+
example_fix: {
|
|
514
|
+
kind: "module",
|
|
515
|
+
name: "test",
|
|
516
|
+
definitions: [{ kind: "fn", id: "fn-001", name: "complex", params: [{ id: "p-001", name: "x", type: { kind: "basic", name: "Int" } }], effects: ["pure"], returnType: { kind: "basic", name: "Int" }, contracts: [], body: [{ kind: "ident", id: "id-001", name: "x" }] }],
|
|
517
|
+
},
|
|
518
|
+
},
|
|
519
|
+
{
|
|
520
|
+
type: "undecidable_predicate",
|
|
521
|
+
pipeline_stage: "contract_verifier",
|
|
522
|
+
fields: [
|
|
523
|
+
{ name: "nodeId", type: "string" },
|
|
524
|
+
{ name: "contractId", type: "string" },
|
|
525
|
+
{ name: "functionName", type: "string" },
|
|
526
|
+
{ name: "unsupportedNodeKind", type: "string" },
|
|
527
|
+
],
|
|
528
|
+
example_cause: {
|
|
529
|
+
kind: "module",
|
|
530
|
+
name: "test",
|
|
531
|
+
definitions: [{ kind: "fn", id: "fn-001", name: "f", params: [{ id: "p-001", name: "x", type: { kind: "basic", name: "Int" } }], effects: ["pure"], returnType: { kind: "basic", name: "Int" }, contracts: [{ kind: "post", id: "post-001", condition: { kind: "call", id: "call-001", fn: "someComplexFn", args: [{ kind: "ident", id: "id-r", name: "result" }] } }], body: [{ kind: "ident", id: "id-001", name: "x" }] }],
|
|
532
|
+
},
|
|
533
|
+
example_fix: {
|
|
534
|
+
kind: "module",
|
|
535
|
+
name: "test",
|
|
536
|
+
definitions: [{ kind: "fn", id: "fn-001", name: "f", params: [{ id: "p-001", name: "x", type: { kind: "basic", name: "Int" } }], effects: ["pure"], returnType: { kind: "basic", name: "Int" }, contracts: [{ kind: "post", id: "post-001", condition: { kind: "binop", id: "cmp-001", op: ">=", left: { kind: "ident", id: "id-r", name: "result" }, right: { kind: "literal", id: "lit-001", value: 0 } } }], body: [{ kind: "ident", id: "id-001", name: "x" }] }],
|
|
537
|
+
},
|
|
538
|
+
},
|
|
539
|
+
{
|
|
540
|
+
type: "precondition_not_met",
|
|
541
|
+
pipeline_stage: "contract_verifier",
|
|
542
|
+
fields: [
|
|
543
|
+
{ name: "nodeId", type: "string" },
|
|
544
|
+
{ name: "callSiteId", type: "string" },
|
|
545
|
+
{ name: "callerName", type: "string" },
|
|
546
|
+
{ name: "calleeName", type: "string" },
|
|
547
|
+
{ name: "contractId", type: "string" },
|
|
548
|
+
{ name: "counterexample", type: "Record<string, unknown>" },
|
|
549
|
+
],
|
|
550
|
+
example_cause: {
|
|
551
|
+
kind: "module",
|
|
552
|
+
name: "test",
|
|
553
|
+
definitions: [
|
|
554
|
+
{ kind: "fn", id: "fn-001", name: "divide", params: [{ id: "p-001", name: "a", type: { kind: "basic", name: "Int" } }, { id: "p-002", name: "b", type: { kind: "basic", name: "Int" } }], effects: ["pure"], returnType: { kind: "basic", name: "Int" }, contracts: [{ kind: "pre", id: "pre-001", condition: { kind: "binop", id: "cmp-001", op: "!=", left: { kind: "ident", id: "id-b", name: "b" }, right: { kind: "literal", id: "lit-z", value: 0 } } }], body: [{ kind: "binop", id: "div-001", op: "/", left: { kind: "ident", id: "id-a", name: "a" }, right: { kind: "ident", id: "id-b2", name: "b" } }] },
|
|
555
|
+
{ kind: "fn", id: "fn-002", name: "main", params: [{ id: "p-003", name: "x", type: { kind: "basic", name: "Int" } }], effects: ["pure"], returnType: { kind: "basic", name: "Int" }, contracts: [], body: [{ kind: "call", id: "call-001", fn: "divide", args: [{ kind: "ident", id: "id-x", name: "x" }, { kind: "literal", id: "lit-001", value: 0 }] }] },
|
|
556
|
+
],
|
|
557
|
+
},
|
|
558
|
+
example_fix: {
|
|
559
|
+
kind: "module",
|
|
560
|
+
name: "test",
|
|
561
|
+
definitions: [
|
|
562
|
+
{ kind: "fn", id: "fn-001", name: "divide", params: [{ id: "p-001", name: "a", type: { kind: "basic", name: "Int" } }, { id: "p-002", name: "b", type: { kind: "basic", name: "Int" } }], effects: ["pure"], returnType: { kind: "basic", name: "Int" }, contracts: [{ kind: "pre", id: "pre-001", condition: { kind: "binop", id: "cmp-001", op: "!=", left: { kind: "ident", id: "id-b", name: "b" }, right: { kind: "literal", id: "lit-z", value: 0 } } }], body: [{ kind: "binop", id: "div-001", op: "/", left: { kind: "ident", id: "id-a", name: "a" }, right: { kind: "ident", id: "id-b2", name: "b" } }] },
|
|
563
|
+
{ kind: "fn", id: "fn-002", name: "main", params: [{ id: "p-003", name: "x", type: { kind: "basic", name: "Int" } }], effects: ["pure"], returnType: { kind: "basic", name: "Int" }, contracts: [], body: [{ kind: "call", id: "call-001", fn: "divide", args: [{ kind: "ident", id: "id-x", name: "x" }, { kind: "literal", id: "lit-001", value: 1 }] }] },
|
|
564
|
+
],
|
|
565
|
+
},
|
|
566
|
+
},
|
|
567
|
+
// =====================================================================
|
|
568
|
+
// Patch errors
|
|
569
|
+
// =====================================================================
|
|
570
|
+
{
|
|
571
|
+
type: "patch_node_not_found",
|
|
572
|
+
pipeline_stage: "patch",
|
|
573
|
+
fields: [
|
|
574
|
+
{ name: "nodeId", type: "string | null" },
|
|
575
|
+
{ name: "patchIndex", type: "number" },
|
|
576
|
+
],
|
|
577
|
+
example_cause: { patches: [{ nodeId: "nonexistent-001", op: "replace", field: "name", value: "fixed" }] },
|
|
578
|
+
example_fix: { patches: [{ nodeId: "fn-main-001", op: "replace", field: "name", value: "fixed" }] },
|
|
579
|
+
},
|
|
580
|
+
{
|
|
581
|
+
type: "patch_invalid_field",
|
|
582
|
+
pipeline_stage: "patch",
|
|
583
|
+
fields: [
|
|
584
|
+
{ name: "nodeId", type: "string" },
|
|
585
|
+
{ name: "field", type: "string" },
|
|
586
|
+
{ name: "availableFields", type: "string[]" },
|
|
587
|
+
{ name: "patchIndex", type: "number" },
|
|
588
|
+
],
|
|
589
|
+
example_cause: { patches: [{ nodeId: "fn-main-001", op: "replace", field: "nonexistent", value: "x" }] },
|
|
590
|
+
example_fix: { patches: [{ nodeId: "fn-main-001", op: "replace", field: "name", value: "x" }] },
|
|
591
|
+
},
|
|
592
|
+
{
|
|
593
|
+
type: "patch_index_out_of_range",
|
|
594
|
+
pipeline_stage: "patch",
|
|
595
|
+
fields: [
|
|
596
|
+
{ name: "nodeId", type: "string" },
|
|
597
|
+
{ name: "field", type: "string" },
|
|
598
|
+
{ name: "index", type: "number" },
|
|
599
|
+
{ name: "arrayLength", type: "number" },
|
|
600
|
+
{ name: "patchIndex", type: "number" },
|
|
601
|
+
],
|
|
602
|
+
example_cause: { patches: [{ nodeId: "fn-main-001", op: "insert", field: "params", index: 999, value: {} }] },
|
|
603
|
+
example_fix: { patches: [{ nodeId: "fn-main-001", op: "insert", field: "params", index: 0, value: {} }] },
|
|
604
|
+
},
|
|
605
|
+
{
|
|
606
|
+
type: "patch_delete_not_in_array",
|
|
607
|
+
pipeline_stage: "patch",
|
|
608
|
+
fields: [
|
|
609
|
+
{ name: "nodeId", type: "string" },
|
|
610
|
+
{ name: "patchIndex", type: "number" },
|
|
611
|
+
],
|
|
612
|
+
example_cause: { patches: [{ nodeId: "fn-main-001", op: "delete" }] },
|
|
613
|
+
example_fix: { patches: [{ nodeId: "fn-main-001", op: "replace", field: "name", value: "updated" }] },
|
|
614
|
+
},
|
|
615
|
+
];
|
|
616
|
+
return { count: errors.length, errors };
|
|
617
|
+
}
|
|
618
|
+
//# sourceMappingURL=error-catalog.js.map
|