1pub struct DiagnosticInfo {
21 pub code: &'static str,
22 pub summary: &'static str,
23 pub grammar_symbol: &'static [&'static str],
31}
32
33pub const REGISTRY: &[DiagnosticInfo] = &[
35 d(
36 "bynk.actor.bearer_identity_not_string_constructible",
37 "A `Bearer` actor's identity is not a string-constructible type.",
38 ),
39 d(
40 "bynk.actor.bearer_missing_secret",
41 "A `Bearer` actor does not name its signing secret.",
42 ),
43 d(
44 "bynk.actor.binder_shadows_param",
45 "A `by` actor binder collides with a handler parameter of the same name.",
46 ),
47 d(
48 "bynk.actor.by_on_agent",
49 "A `by` actor clause was placed on an agent `on call` handler, which has no actor.",
50 ),
51 d(
52 "bynk.actor.duplicate_sum_scheme",
53 "Two peers in a multi-actor sum share an authentication scheme.",
54 ),
55 d(
56 "bynk.actor.identity_not_sealed",
57 "An actor identity type is not a context-ownable (sealed) value type.",
58 ),
59 d(
60 "bynk.actor.missing_by_on_http",
61 "An HTTP handler lacks the required `by` actor clause.",
62 ),
63 d(
64 "bynk.actor.outside_context",
65 "An `actor` was declared outside a context (e.g. in a commons).",
66 ),
67 d(
68 "bynk.actor.refinement_base_unsupported",
69 "A refinement actor's base is not a `Bearer` actor (no claims to authorise against).",
70 ),
71 d(
72 "bynk.actor.refinement_in_sum",
73 "A refinement actor appears as a member of a multi-actor sum.",
74 ),
75 d(
76 "bynk.actor.refinement_predicate_unsupported",
77 "A refinement actor's `where` predicate is outside the closed claim-predicate set.",
78 ),
79 d(
80 "bynk.actor.scheme_not_admissible",
81 "An actor's scheme is not admissible on this handler's protocol.",
82 ),
83 d(
84 "bynk.actor.signature_identity_unsupported",
85 "A `Signature` actor declared an `identity`, which is not yet supported.",
86 ),
87 d(
88 "bynk.actor.signature_missing_header",
89 "A `Signature` actor does not name its signature header.",
90 ),
91 d(
92 "bynk.actor.signature_missing_secret",
93 "A `Signature` actor does not name its signing secret.",
94 ),
95 d(
96 "bynk.actor.signature_requires_body",
97 "A `Signature` handler does not take a `body` parameter.",
98 ),
99 d(
100 "bynk.actor.signature_tolerance_without_timestamp",
101 "A `Signature` actor set `tolerance` without a `timestamp` header.",
102 ),
103 d(
104 "bynk.actor.sum_requires_binder",
105 "A multi-actor sum `by` clause has no binder to match the resolved actor.",
106 ),
107 d(
108 "bynk.actor.unknown_actor",
109 "A handler's `by` clause names an actor that is not declared.",
110 ),
111 d(
112 "bynk.actor.unknown_scheme",
113 "An actor declares an authentication scheme that is not compiler-known.",
114 ),
115 d(
116 "bynk.actor.unreachable_sum_arm",
117 "A multi-actor sum has an arm unreachable after a catch-all (`None`) peer.",
118 ),
119 dg(
120 "bynk.adapter.consumes_context",
121 "An `adapter` consumed a context; adapter dependencies are adapter-to-adapter.",
122 &["consumes_decl"],
123 ),
124 dg(
125 "bynk.adapter.consumes_requires_selection",
126 "An `adapter` used a whole-unit or aliased `consumes`; adapters must select capabilities with `consumes U { Cap, … }`.",
127 &["consumes_decl"],
128 ),
129 dg(
130 "bynk.adapter.disallowed_item",
131 "An `adapter` declared a `service`, `agent`, or other item it may not contain.",
132 &["adapter_decl"],
133 ),
134 dg(
135 "bynk.adapter.duplicate_binding",
136 "An `adapter` declared more than one `binding` clause.",
137 &["binding_decl"],
138 ),
139 dg(
140 "bynk.adapter.no_binding",
141 "An `adapter` declares an external provider but no `binding` module to supply it.",
142 &["adapter_decl"],
143 ),
144 dg(
145 "bynk.adapter.provider_has_body",
146 "A provider inside an `adapter` has a Bynk body; adapter providers must be external.",
147 &["provider_decl"],
148 ),
149 dg(
150 "bynk.agent.construction_arity",
151 "An agent was constructed with the wrong number of key arguments.",
152 &["agent_decl"],
153 ),
154 dg(
155 "bynk.agent.handler_arity",
156 "An agent handler was called with the wrong number of arguments.",
157 &["agent_decl"],
158 ),
159 dg(
160 "bynk.agent.handler_not_found",
161 "Called a handler the agent does not declare.",
162 &["agent_decl"],
163 ),
164 dg(
165 "bynk.agent.key_mismatch",
166 "An agent key argument has the wrong type.",
167 &["agent_decl"],
168 ),
169 dg(
170 "bynk.agent.outside_context",
171 "An `agent` was declared outside a context.",
172 &["agent_decl"],
173 ),
174 dg(
175 "bynk.agent.return_not_effect",
176 "An agent handler's return type is not an `Effect`.",
177 &["agent_decl"],
178 ),
179 dg(
180 "bynk.agents.bad_state_initialiser",
181 "An agent `store` field initialiser is not a static value of the field's type.",
182 &["store_field"],
183 ),
184 dg(
185 "bynk.agents.non_zeroable_state_field",
186 "An agent `store` field has no initialiser and no implicit zero value.",
187 &["store_field"],
188 ),
189 dg(
190 "bynk.assert.non_bool",
191 "`assert` was given a non-`Bool` expression.",
192 &["assert_expr"],
193 ),
194 dg(
195 "bynk.assert.outside_test",
196 "`assert` was used outside a test case body.",
197 &["assert_expr"],
198 ),
199 d(
200 "bynk.boundary.structural_mismatch",
201 "Data crossing a context boundary did not match the expected shape.",
202 ),
203 dg(
204 "bynk.capability.op_arity",
205 "A capability operation was called with the wrong number of arguments.",
206 &["capability_decl"],
207 ),
208 dg(
209 "bynk.capability.outside_context",
210 "A `capability` was declared outside a context.",
211 &["capability_decl"],
212 ),
213 dg(
214 "bynk.capability.unknown_operation",
215 "Referenced an operation the capability does not declare.",
216 &["capability_decl"],
217 ),
218 d(
219 "bynk.cell.invalid_target",
220 "A `:=` write targets something that is not a `store Cell` field.",
221 ),
222 d(
223 "bynk.cell.self_reference",
224 "A `:=` right-hand side reads the cell being written (a read-modify-write); use `.update`.",
225 ),
226 dg(
227 "bynk.consumes.alias_conflict",
228 "Two `consumes` aliases collide.",
229 &["consumes_decl"],
230 ),
231 dg(
232 "bynk.consumes.capability_name_clash",
233 "Two flattened `consumes U { Cap }` capabilities collide, or one clashes with a local capability.",
234 &["consumes_decl"],
235 ),
236 dg(
237 "bynk.consumes.in_commons",
238 "`consumes` appears in a `commons` (it is only valid in a context).",
239 &["consumes_decl"],
240 ),
241 dg(
242 "bynk.consumes.name_conflict",
243 "A `consumes` name collides with another name in scope.",
244 &["consumes_decl"],
245 ),
246 dg(
247 "bynk.consumes.self_reference",
248 "A context `consumes` itself.",
249 &["consumes_decl"],
250 ),
251 dg(
252 "bynk.consumes.service_arity",
253 "A consumed service was called with the wrong number of arguments.",
254 &["consumes_decl"],
255 ),
256 dg(
257 "bynk.consumes.target_is_commons",
258 "`consumes` targets a `commons` instead of a context.",
259 &["consumes_decl"],
260 ),
261 dg(
262 "bynk.consumes.unknown_context",
263 "`consumes` names a context that does not exist.",
264 &["consumes_decl"],
265 ),
266 dg(
267 "bynk.consumes.unknown_service",
268 "Called a service the consumed context does not declare.",
269 &["consumes_decl"],
270 ),
271 d(
272 "bynk.context.consumes_cycle",
273 "Contexts form a `consumes` dependency cycle.",
274 ),
275 d(
276 "bynk.context.external_construction",
277 "A context-owned type was constructed from outside that context.",
278 ),
279 dg(
280 "bynk.context.external_provider",
281 "A bodiless (external) provider was declared outside an `adapter`.",
282 &["provider_decl"],
283 ),
284 d(
285 "bynk.context.opaque_inspection",
286 "An opaquely-exported type was inspected from outside its context.",
287 ),
288 dg(
289 "bynk.cron.bad_params",
290 "A cron handler declares more than one parameter, or a non-`Int` one.",
291 &["cron_handler"],
292 ),
293 dg(
294 "bynk.cron.duplicate_schedule",
295 "Two cron handlers declare the same schedule.",
296 &["cron_handler"],
297 ),
298 dg(
299 "bynk.cron.invalid_schedule",
300 "A cron expression is not five whitespace-separated fields.",
301 &["cron_handler"],
302 ),
303 dg(
304 "bynk.cron.return_not_effect_result",
305 "A cron handler does not return `Effect[Result[(), E]]`.",
306 &["cron_handler"],
307 ),
308 d(
309 "bynk.duration.literal_overflow",
310 "A `Duration` literal (`<int>.<unit>`) exceeds the representable millisecond range.",
311 ),
312 dg(
313 "bynk.effect.bind_in_pure_context",
314 "An `<-` bind was used in a pure (non-effectful) context.",
315 &["effect_let_stmt"],
316 ),
317 dg(
318 "bynk.effect.bind_on_non_effect",
319 "An `<-` bind was applied to a non-`Effect` value.",
320 &["effect_let_stmt"],
321 ),
322 d(
323 "bynk.effect.capability_in_pure_context",
324 "A capability was used in a pure context.",
325 ),
326 d(
327 "bynk.effect.cross_context_in_pure_context",
328 "A cross-context call was made in a pure context.",
329 ),
330 dg(
331 "bynk.effect.fn_value_in_pure_context",
332 "An effectful function value was called in a pure context; like a capability call, it is legal only where the enclosing body is effectful.",
333 &["call"],
334 ),
335 dg(
336 "bynk.exports.capability_not_provided",
337 "An exported capability has no provider in its context.",
338 &["exports_decl"],
339 ),
340 dg(
341 "bynk.exports.conflicting_visibility",
342 "A type is exported with conflicting visibilities.",
343 &["exports_decl"],
344 ),
345 dg(
346 "bynk.exports.duplicate_export",
347 "The same name is exported more than once.",
348 &["exports_decl"],
349 ),
350 dg(
351 "bynk.exports.duplicate_in_clause",
352 "A name appears twice in one `exports` clause.",
353 &["exports_decl"],
354 ),
355 dg(
356 "bynk.exports.undeclared_capability",
357 "`exports capability` names a capability that is not declared.",
358 &["exports_decl"],
359 ),
360 dg(
361 "bynk.exports.undeclared_type",
362 "`exports` names a type that is not declared.",
363 &["exports_decl"],
364 ),
365 dg(
366 "bynk.generics.no_bounds",
367 "A type parameter carries a bound (`[A: …]`); bounded generics are not in v0.20a.",
368 &["fn_decl"],
369 ),
370 dg(
371 "bynk.generics.no_generic_types",
372 "A `type` declaration carries a type-parameter list; generic type declarations are not in v0.20a (type parameters belong to functions).",
373 &["type_decl"],
374 ),
375 dg(
376 "bynk.generics.type_arg_mismatch",
377 "Inferred or explicit type arguments conflict, have the wrong arity, target a non-generic function, or a type parameter shadows a declared type.",
378 &["call"],
379 ),
380 dg(
381 "bynk.generics.uninferable_type_arg",
382 "A generic function's type parameter could not be inferred from the arguments and was not given explicitly (`name[T](…)`); a bare generic function also cannot be passed as a value in v0.20a.",
383 &["call"],
384 ),
385 dg(
386 "bynk.given.cross_context_unknown_capability",
387 "`given B.Cap` names a capability the consumed context does not export.",
388 &["given_clause"],
389 ),
390 dg(
391 "bynk.given.undeclared_capability",
392 "A handler uses a capability it did not declare with `given`.",
393 &["given_clause"],
394 ),
395 dg(
396 "bynk.given.unknown_capability",
397 "`given` names a capability that does not exist.",
398 &["given_clause"],
399 ),
400 dg(
401 "bynk.given.unused_capability",
402 "A `given` capability is never used (warning).",
403 &["given_clause"],
404 ),
405 dg(
406 "bynk.http.body_on_get_or_delete",
407 "A GET or DELETE handler declares a `body` parameter.",
408 &["http_handler"],
409 ),
410 dg(
411 "bynk.http.duplicate_route",
412 "Two handlers share the same method and route.",
413 &["http_handler"],
414 ),
415 dg(
416 "bynk.http.extra_param",
417 "A handler parameter is neither a path parameter nor `body`.",
418 &["http_handler"],
419 ),
420 dg(
421 "bynk.http.invalid_path",
422 "An HTTP route path is malformed.",
423 &["http_handler"],
424 ),
425 dg(
426 "bynk.http.path_param_not_stringy",
427 "A path parameter's type is not constructible from a string.",
428 &["http_handler"],
429 ),
430 dg(
431 "bynk.http.reserved_prefix",
432 "A route uses the reserved `/_bynk/` prefix.",
433 &["http_handler"],
434 ),
435 dg(
436 "bynk.http.return_not_effect_http_result",
437 "An HTTP handler does not return `Effect[HttpResult[T]]`.",
438 &["http_handler"],
439 ),
440 dg(
441 "bynk.http.unbound_path_param",
442 "A `:name` route segment has no matching handler parameter.",
443 &["http_handler"],
444 ),
445 d(
446 "bynk.index.bad_argument",
447 "An `@indexed` argument is not a `by: <field>` label.",
448 ),
449 d(
450 "bynk.index.missing",
451 "A query filters a map by equality on a field that is not `@indexed` (a perf-hint warning).",
452 ),
453 d(
454 "bynk.index.unkeyable_key",
455 "An `@indexed(by: k)` field is not value-keyable.",
456 ),
457 d(
458 "bynk.index.unknown_key",
459 "An `@indexed(by: k)` field is not a field of the map's value type.",
460 ),
461 d(
462 "bynk.index.unused",
463 "A declared `@indexed(by: k)` is never used by an equality filter (a hygiene warning).",
464 ),
465 dg(
466 "bynk.integration.duplicate_participant",
467 "A context is listed more than once in a `wires` clause.",
468 &["wires_decl"],
469 ),
470 dg(
471 "bynk.integration.duplicate_suite",
472 "Two integration tests share the same suite name.",
473 &["integration_decl"],
474 ),
475 dg(
476 "bynk.integration.mock_in_integration",
477 "`mocks` is not allowed in an integration test.",
478 &["mocks_decl"],
479 ),
480 dg(
481 "bynk.integration.too_few_participants",
482 "An integration test wires fewer than two contexts.",
483 &["wires_decl"],
484 ),
485 dg(
486 "bynk.integration.unknown_participant",
487 "A `wires` clause names something that is not a declared context.",
488 &["wires_decl"],
489 ),
490 dg(
491 "bynk.integration.unwired_dependency",
492 "A participant consumes a context that is not wired into the integration test.",
493 &["integration_decl"],
494 ),
495 d(
496 "bynk.invariant.cross_agent_reference",
497 "An invariant predicate references another agent; invariants are per-agent.",
498 ),
499 d(
500 "bynk.invariant.duplicate_name",
501 "An agent declares two invariants with the same name.",
502 ),
503 d(
504 "bynk.invariant.impure_predicate",
505 "An invariant predicate uses an effectful or test-only construct.",
506 ),
507 d(
508 "bynk.invariant.not_bool",
509 "An invariant predicate does not have type `Bool`.",
510 ),
511 dg(
512 "bynk.lambda.unannotated_param",
513 "A lambda parameter has no type annotation in a position where no function type is expected to infer it from.",
514 &["lambda_expr"],
515 ),
516 dg(
517 "bynk.lex.bad_escape",
518 "An invalid escape sequence in a string literal.",
519 &["string_literal"],
520 ),
521 dg(
522 "bynk.lex.float_literal_overflow",
523 "A float literal does not fit a finite 64-bit float.",
524 &["float_literal"],
525 ),
526 dg(
527 "bynk.lex.integer_overflow",
528 "An integer literal is out of range.",
529 &["number_literal"],
530 ),
531 d(
532 "bynk.lex.unclosed_doc_block",
533 "A documentation block is not closed.",
534 ),
535 d(
536 "bynk.lex.unexpected_character",
537 "An unexpected character in the source.",
538 ),
539 dg(
540 "bynk.lex.unterminated_interpolation",
541 "An interpolation hole `\\(…)` is not closed on its line.",
542 &["string_literal"],
543 ),
544 dg(
545 "bynk.lex.unterminated_string",
546 "A string literal is not terminated.",
547 &["string_literal"],
548 ),
549 d(
550 "bynk.list.deprecated_function",
551 "A `bynk.list` free function (`map`/`filter`/`find`/`any`/`all`) is deprecated in favour of the `List` method form (warning; auto-fixable).",
552 ),
553 dg(
554 "bynk.mock.arity",
555 "`Mock[T]` was given the wrong number of pin arguments.",
556 &["mock_expr"],
557 ),
558 dg(
559 "bynk.mock.duplicate_target",
560 "A `mocks` target is declared more than once.",
561 &["mocks_decl"],
562 ),
563 dg(
564 "bynk.mock.in_commons_test",
565 "`mocks` used in a commons test, where there is no dependency to inject.",
566 &["mocks_decl"],
567 ),
568 dg(
569 "bynk.mock.literal_violates",
570 "A pinned `Mock[T]` value violates the type's refinement.",
571 &["mock_expr"],
572 ),
573 dg(
574 "bynk.mock.needs_pin",
575 "A bare `Mock[T]` cannot generate a value (e.g. a `Matches` string); pin one.",
576 &["mock_expr"],
577 ),
578 dg(
579 "bynk.mock.outside_test",
580 "`Mock[T]` was used outside a test case body.",
581 &["mock_expr"],
582 ),
583 dg(
584 "bynk.mock.pin_not_literal",
585 "A `Mock[T]` pin argument is not a compile-time literal.",
586 &["mock_expr"],
587 ),
588 dg(
589 "bynk.mock.pin_unsupported",
590 "A pin was given for a type kind that does not support pinning.",
591 &["mock_expr"],
592 ),
593 dg(
594 "bynk.mock.signature_mismatch",
595 "A `mocks` implementation's signature does not match the capability.",
596 &["mocks_decl"],
597 ),
598 dg(
599 "bynk.mock.unknown_target",
600 "`mocks` names a capability that is not in scope.",
601 &["mocks_decl"],
602 ),
603 dg(
604 "bynk.mock.unknown_type",
605 "`Mock[T]` names a type that does not resolve.",
606 &["mock_expr"],
607 ),
608 dg(
609 "bynk.mock.unsupported_kind",
610 "`Mock[T]` cannot fabricate a value for this kind of type.",
611 &["mock_expr"],
612 ),
613 d(
614 "bynk.namespace.reserved",
615 "A user unit is named `bynk` or `bynk.*`; the `bynk` root is reserved for the toolchain.",
616 ),
617 dg(
618 "bynk.parse.consumes_after_decls",
619 "`consumes` appears after other declarations.",
620 &["consumes_decl"],
621 ),
622 dg(
623 "bynk.parse.empty_agent",
624 "An `agent` body is empty.",
625 &["agent_decl"],
626 ),
627 dg(
628 "bynk.parse.empty_capability",
629 "A `capability` body is empty.",
630 &["capability_decl"],
631 ),
632 d(
633 "bynk.parse.empty_interpolation",
634 "An interpolation hole `\\(…)` contains no expression.",
635 ),
636 dg(
637 "bynk.parse.empty_match",
638 "A `match` has no arms.",
639 &["match_expr"],
640 ),
641 dg(
642 "bynk.parse.empty_mock_body",
643 "A `mocks` body is empty.",
644 &["mocks_decl"],
645 ),
646 dg(
647 "bynk.parse.empty_service",
648 "A `service` body is empty.",
649 &["service_decl"],
650 ),
651 dg(
652 "bynk.parse.expected_agent_key",
653 "Expected a `key` declaration in an agent.",
654 &["agent_decl"],
655 ),
656 d(
657 "bynk.parse.expected_agent_storage",
658 "An agent declares no storage — it has no `store` fields.",
659 ),
660 dg(
661 "bynk.parse.expected_base_type",
662 "Expected a base type.",
663 &["base_type"],
664 ),
665 dg(
666 "bynk.parse.expected_capability_op",
667 "Expected a capability operation.",
668 &["capability_op"],
669 ),
670 d("bynk.parse.expected_expression", "Expected an expression."),
671 dg(
672 "bynk.parse.expected_handler",
673 "Expected a handler.",
674 &["handler"],
675 ),
676 d("bynk.parse.expected_item", "Expected a declaration."),
677 dg(
678 "bynk.parse.expected_predicate",
679 "Expected a refinement predicate.",
680 &["refinement"],
681 ),
682 dg(
683 "bynk.parse.expected_provider_op",
684 "Expected a provider operation.",
685 &["provider_op"],
686 ),
687 d("bynk.parse.expected_token", "Expected a specific token."),
688 d("bynk.parse.expected_type", "Expected a type."),
689 d(
690 "bynk.parse.expected_unit_header",
691 "Expected a `commons` or `context` header.",
692 ),
693 dg(
694 "bynk.parse.expected_visibility",
695 "Expected a visibility keyword.",
696 &["exports_decl"],
697 ),
698 dg(
699 "bynk.parse.exports_after_decls",
700 "`exports` appears after other declarations.",
701 &["exports_decl"],
702 ),
703 d(
704 "bynk.parse.extra_tokens",
705 "Unexpected tokens after an otherwise complete construct.",
706 ),
707 dg(
708 "bynk.parse.generic_arg_count",
709 "Wrong number of generic type arguments.",
710 &["generic_type_ref"],
711 ),
712 dg(
713 "bynk.parse.handler_in_agent",
714 "A protocol handler (`on GET`/`schedule`/`message`) was declared in an agent.",
715 &["handler"],
716 ),
717 d(
718 "bynk.parse.invariant_after_handler",
719 "An `invariant` was declared after a handler; invariants precede handlers.",
720 ),
721 dg(
722 "bynk.parse.malformed_float_literal",
723 "A float literal is missing a digit on one side of the `.` (`1.`, `.5`).",
724 &["float_literal"],
725 ),
726 dg(
727 "bynk.parse.non_associative",
728 "A non-associative operator was chained (e.g. `a == b == c`).",
729 &["binary_expr"],
730 ),
731 d(
732 "bynk.parse.orphan_doc_block",
733 "A documentation block is not attached to a declaration (warning).",
734 ),
735 dg(
736 "bynk.parse.reserved_keyword",
737 "A reserved keyword was used as an identifier.",
738 &["identifier"],
739 ),
740 dg(
741 "bynk.parse.self_outside_method",
742 "`self` used outside a method or handler.",
743 &["self_expr"],
744 ),
745 d(
746 "bynk.parse.storage_after_phase",
747 "Agent storage (`state` / `store`) is declared after the invariants or handlers.",
748 ),
749 d(
750 "bynk.parse.unexpected_adapter",
751 "An `adapter` appeared where it is not allowed.",
752 ),
753 dg(
754 "bynk.parse.unexpected_context",
755 "A `context` appeared where it is not allowed.",
756 &["context_decl"],
757 ),
758 d("bynk.parse.unexpected_eof", "Unexpected end of input."),
759 dg(
760 "bynk.parse.unexpected_test",
761 "A `test` appeared where it is not allowed.",
762 &["test_decl"],
763 ),
764 d(
765 "bynk.parse.unknown_effect_method",
766 "An unknown method on `Effect`.",
767 ),
768 dg(
769 "bynk.parse.unknown_handler_kind",
770 "An unknown handler form (expected `call`, an HTTP method, `schedule`, or `message`).",
771 &["handler"],
772 ),
773 dg(
774 "bynk.parse.unknown_predicate",
775 "An unknown refinement predicate.",
776 &["predicate_name"],
777 ),
778 dg(
779 "bynk.parse.uses_after_decls",
780 "`uses` appears after other declarations.",
781 &["uses_decl"],
782 ),
783 d(
784 "bynk.project.file_and_directory",
785 "A unit exists as both a file and a directory.",
786 ),
787 d(
788 "bynk.project.inconsistent_commons_name",
789 "A source file's path does not match its declared name.",
790 ),
791 d(
792 "bynk.project.inconsistent_test_path",
793 "A test file's path does not match its target's name.",
794 ),
795 d(
796 "bynk.project.kind_conflict",
797 "A name is declared as both a commons and a context.",
798 ),
799 d(
800 "bynk.project.no_root",
801 "No project root could be determined.",
802 ),
803 d(
804 "bynk.project.no_sources",
805 "The project contains no source files.",
806 ),
807 d(
808 "bynk.project.read_failed",
809 "A source file could not be read.",
810 ),
811 dg(
812 "bynk.provider.dependency_cycle",
813 "Providers form a capability dependency cycle through `given`.",
814 &["provider_decl"],
815 ),
816 dg(
817 "bynk.provider.extra_operation",
818 "A `provides` block implements an operation not in the capability.",
819 &["provider_decl"],
820 ),
821 dg(
822 "bynk.provider.missing_operation",
823 "A `provides` block is missing a capability operation.",
824 &["provider_decl"],
825 ),
826 dg(
827 "bynk.provider.outside_context",
828 "`provides` was declared outside a context.",
829 &["provider_decl"],
830 ),
831 dg(
832 "bynk.provider.signature_mismatch",
833 "A `provides` operation's signature does not match the capability.",
834 &["provider_decl"],
835 ),
836 dg(
837 "bynk.provider.unknown_capability",
838 "`provides` names a capability that does not exist.",
839 &["provider_decl"],
840 ),
841 d(
842 "bynk.query.join_key_mismatch",
843 "A `joinOn`/`leftJoin` left and right key function return different types.",
844 ),
845 dg(
846 "bynk.query.sum_needs_numeric",
847 "A `sum`/`average` key function does not return a numeric type (`Int`, `Float`, or `Duration`).",
848 &[],
849 ),
850 dg(
851 "bynk.queue.bad_params",
852 "An `on message` handler does not take exactly one `message` parameter.",
853 &["queue_handler"],
854 ),
855 dg(
856 "bynk.queue.duplicate_consumer",
857 "Two `on message` handlers consume the same queue.",
858 &["queue_handler"],
859 ),
860 dg(
861 "bynk.queue.invalid_name",
862 "A `from queue(\"…\")` binding has an empty queue name.",
863 &["queue_handler"],
864 ),
865 dg(
866 "bynk.queue.return_not_queue_result",
867 "An `on message` handler does not return `Effect[QueueResult]`.",
868 &["handler"],
869 ),
870 dg(
871 "bynk.record_spread.field_type_mismatch",
872 "A record-spread override has the wrong type for the field.",
873 &["record_spread"],
874 ),
875 dg(
876 "bynk.record_spread.non_record_base",
877 "The base of a record spread is not a record.",
878 &["record_spread"],
879 ),
880 dg(
881 "bynk.record_spread.type_mismatch",
882 "A record spread's base is a different record type.",
883 &["record_spread"],
884 ),
885 dg(
886 "bynk.record_spread.unknown_field",
887 "A record spread overrides a field the record does not have.",
888 &["record_spread"],
889 ),
890 dg(
891 "bynk.refine.literal_violates",
892 "A literal does not satisfy the refined type's predicate.",
893 &["refined_type"],
894 ),
895 dg(
896 "bynk.requires.unpinned_dependency",
897 "An adapter `binding … requires { … }` entry has an unpinned version range.",
898 &["binding_decl"],
899 ),
900 d(
901 "bynk.resolve.ambiguous_variant",
902 "A variant name is ambiguous across several sum types.",
903 ),
904 dg(
905 "bynk.resolve.arity_mismatch",
906 "A function was called with the wrong number of arguments.",
907 &["call"],
908 ),
909 d("bynk.resolve.duplicate_actor", "Two actors share a name."),
910 dg(
911 "bynk.resolve.duplicate_agent",
912 "Two agents share a name.",
913 &["agent_decl"],
914 ),
915 dg(
916 "bynk.resolve.duplicate_capability",
917 "Two capabilities share a name.",
918 &["capability_decl"],
919 ),
920 dg(
921 "bynk.resolve.duplicate_field",
922 "A record declares a field twice.",
923 &["record_type"],
924 ),
925 dg(
926 "bynk.resolve.duplicate_field_init",
927 "A record construction initialises a field twice.",
928 &["record_construction"],
929 ),
930 dg(
931 "bynk.resolve.duplicate_fn",
932 "Two functions share a name.",
933 &["fn_decl"],
934 ),
935 dg(
936 "bynk.resolve.duplicate_method",
937 "Two methods share a name.",
938 &["fn_decl"],
939 ),
940 dg(
941 "bynk.resolve.duplicate_param",
942 "A parameter name is repeated.",
943 &["param"],
944 ),
945 dg(
946 "bynk.resolve.duplicate_provider",
947 "A capability is provided more than once.",
948 &["provider_decl"],
949 ),
950 dg(
951 "bynk.resolve.duplicate_service",
952 "Two services share a name.",
953 &["service_decl"],
954 ),
955 dg(
956 "bynk.resolve.duplicate_type",
957 "Two types share a name.",
958 &["type_decl"],
959 ),
960 dg(
961 "bynk.resolve.duplicate_variant",
962 "A sum type declares a variant twice.",
963 &["sum_type"],
964 ),
965 d(
966 "bynk.resolve.fn_without_call",
967 "A function was referenced without being called.",
968 ),
969 dg(
970 "bynk.resolve.let_shadows_fn",
971 "A `let` binding shadows a function.",
972 &["let_stmt"],
973 ),
974 dg(
975 "bynk.resolve.let_shadows_type",
976 "A `let` binding shadows a type.",
977 &["let_stmt"],
978 ),
979 d(
980 "bynk.resolve.method_unknown_type",
981 "A method is defined on an unknown type.",
982 ),
983 dg(
984 "bynk.resolve.missing_field",
985 "A record construction omits a required field.",
986 &["record_construction"],
987 ),
988 d(
989 "bynk.resolve.name_conflict",
990 "Two declarations share a name.",
991 ),
992 dg(
993 "bynk.resolve.not_a_record_type",
994 "Record syntax was used on a non-record type.",
995 &["record_construction"],
996 ),
997 dg(
998 "bynk.resolve.opaque_record_construction",
999 "An opaque type was constructed with record syntax.",
1000 &["record_construction"],
1001 ),
1002 dg(
1003 "bynk.resolve.param_as_function",
1004 "A value (such as a parameter) was called as a function.",
1005 &["call"],
1006 ),
1007 dg(
1008 "bynk.resolve.recursive_record_field",
1009 "A record directly contains a field of its own type.",
1010 &["record_type"],
1011 ),
1012 dg(
1013 "bynk.resolve.self_outside_method",
1014 "`self` referenced outside a method or handler.",
1015 &["self_expr"],
1016 ),
1017 dg(
1018 "bynk.resolve.type_as_function",
1019 "A type name was called as if it were a function.",
1020 &["call"],
1021 ),
1022 d(
1023 "bynk.resolve.type_in_expr",
1024 "A type name was used where a value is expected.",
1025 ),
1026 dg(
1027 "bynk.resolve.unconsumed_context",
1028 "A context's service was called without a `consumes` declaration.",
1029 &["consumes_decl"],
1030 ),
1031 dg(
1032 "bynk.resolve.unknown_field",
1033 "Accessed a field the record does not have.",
1034 &["field_access"],
1035 ),
1036 dg(
1037 "bynk.resolve.unknown_function",
1038 "Called a function that does not exist.",
1039 &["call"],
1040 ),
1041 d(
1042 "bynk.resolve.unknown_name",
1043 "Referenced a name that is not in scope.",
1044 ),
1045 dg(
1046 "bynk.resolve.unknown_static_member",
1047 "Referenced an unknown static member (e.g. `T.x`).",
1048 &["field_access"],
1049 ),
1050 d(
1051 "bynk.resolve.unknown_type",
1052 "Referenced a type that does not exist.",
1053 ),
1054 dg(
1055 "bynk.send.in_pure_context",
1056 "A `~>` send was used in a pure (non-effectful) context.",
1057 &["effect_send_stmt"],
1058 ),
1059 dg(
1060 "bynk.send.non_effect",
1061 "A `~>` send was applied to a non-`Effect` value.",
1062 &["effect_send_stmt"],
1063 ),
1064 dg(
1065 "bynk.send.requires_unit",
1066 "A `~>` send targets an operation whose reply is not `Effect[()]`.",
1067 &["effect_send_stmt"],
1068 ),
1069 dg(
1070 "bynk.service.missing_from",
1071 "A `from`-less service has a handler other than `on call`.",
1072 &["service_decl"],
1073 ),
1074 dg(
1075 "bynk.service.mixed_protocols",
1076 "A service mixes handler forms that do not match its `from <protocol>`.",
1077 &["service_decl"],
1078 ),
1079 dg(
1080 "bynk.service.outside_context",
1081 "A `service` was declared outside a context.",
1082 &["service_decl"],
1083 ),
1084 dg(
1085 "bynk.service.return_not_effect",
1086 "A service handler's return type is not an `Effect`.",
1087 &["service_decl"],
1088 ),
1089 dg(
1090 "bynk.service.unknown_protocol",
1091 "A `from <protocol>` names an unknown protocol (e.g. a transport like Kafka).",
1092 &["service_decl"],
1093 ),
1094 d(
1095 "bynk.store.annotation_kind_mismatch",
1096 "A storage annotation is used on a kind it does not apply to (e.g. `@ttl` on a `Map`).",
1097 ),
1098 d(
1099 "bynk.store.annotation_unsupported",
1100 "A known storage annotation (`@ttl`/`@retain`/`@indexed`/`@bounded`) is used before the slice that supports it.",
1101 ),
1102 d(
1103 "bynk.store.cache_needs_clock",
1104 "A handler performs a `Cache` operation (TTL expiry reads the clock) without declaring `given Clock`.",
1105 ),
1106 d(
1107 "bynk.store.cache_ttl_required",
1108 "A `Cache` field is missing its required `@ttl(<duration>)` annotation (a keyed store with no expiry is a `Map`).",
1109 ),
1110 d(
1111 "bynk.store.kind_arity",
1112 "A storage kind was applied to the wrong number of type arguments (e.g. `Cell[A, B]`).",
1113 ),
1114 d(
1115 "bynk.store.kind_unsupported",
1116 "A known storage kind (`Queue`) is used before the slice that supports it.",
1117 ),
1118 d(
1119 "bynk.store.log_needs_clock",
1120 "A handler calls `Log.append` (which stamps the current time) without declaring `given Clock`.",
1121 ),
1122 d(
1123 "bynk.store.unknown_annotation",
1124 "A `store` field carries an annotation outside the closed `@indexed`/`@ttl`/`@retain`/`@bounded` set.",
1125 ),
1126 d(
1127 "bynk.store.unknown_kind",
1128 "A `store` field's type is not a known storage kind.",
1129 ),
1130 d(
1131 "bynk.store.unknown_op",
1132 "A storage-`Map`/`Set` operation is not a recognised entry/membership method.",
1133 ),
1134 dg(
1135 "bynk.target.vendor_conflict",
1136 "One deployment unit's in-process closure uses platform-native capabilities from two mutually-exclusive platforms.",
1137 &["consumes_decl"],
1138 ),
1139 dg(
1140 "bynk.target.vendor_required",
1141 "A deployment unit uses a platform-native capability but the build selects another `--platform`.",
1142 &["consumes_decl"],
1143 ),
1144 dg(
1145 "bynk.test.duplicate_case_name",
1146 "Two test cases share a description.",
1147 &["test_case"],
1148 ),
1149 dg(
1150 "bynk.test.unknown_target",
1151 "A `test` block targets a unit that does not exist.",
1152 &["test_decl"],
1153 ),
1154 d(
1155 "bynk.types.ambiguous_constructor",
1156 "`Ok`/`Err` is ambiguous between `Result` and `HttpResult`; qualify it.",
1157 ),
1158 dg(
1159 "bynk.types.argument_mismatch",
1160 "A function argument has the wrong type.",
1161 &["call"],
1162 ),
1163 dg(
1164 "bynk.types.call_arity",
1165 "A function value was applied with the wrong number of arguments.",
1166 &["call"],
1167 ),
1168 dg(
1169 "bynk.types.cannot_infer_option_type_param",
1170 "The value type of `None` could not be inferred.",
1171 &["none_expr"],
1172 ),
1173 d(
1174 "bynk.types.cannot_infer_result_type_params",
1175 "The type parameters of a `Result` could not be inferred.",
1176 ),
1177 d(
1178 "bynk.types.constructor_arity",
1179 "A variant constructor got the wrong number of arguments.",
1180 ),
1181 d(
1182 "bynk.types.constructor_base_mismatch",
1183 "A `.of` constructor was given an argument of the wrong base type.",
1184 ),
1185 dg(
1186 "bynk.types.duplicate_variant_arm",
1187 "A `match` has two arms for the same variant.",
1188 &["match_arm"],
1189 ),
1190 dg(
1191 "bynk.types.empty_refinement",
1192 "A refinement admits no values (contradictory predicates).",
1193 &["refinement"],
1194 ),
1195 dg(
1196 "bynk.types.err_value_mismatch",
1197 "An `Err` payload has the wrong type.",
1198 &["err_expr"],
1199 ),
1200 dg(
1201 "bynk.types.field_access_on_non_record",
1202 "Field access on a value that is not a record.",
1203 &["field_access"],
1204 ),
1205 dg(
1206 "bynk.types.field_refinement_not_base",
1207 "An inline field refinement requires a base or refined type.",
1208 &["record_field"],
1209 ),
1210 dg(
1211 "bynk.types.field_value_mismatch",
1212 "A record field was given a value of the wrong type.",
1213 &["record_construction"],
1214 ),
1215 dg(
1216 "bynk.types.function_at_boundary",
1217 "A function type appeared in a serialisable or boundary position (a record field, sum payload, service/agent handler signature, capability operation signature, agent state field, or agent key); functions cannot serialise or cross a boundary.",
1218 &["function_type_ref"],
1219 ),
1220 dg(
1221 "bynk.types.if_branch_mismatch",
1222 "The branches of an `if` have different types.",
1223 &["if_expr"],
1224 ),
1225 dg(
1226 "bynk.types.if_non_bool_cond",
1227 "An `if` condition is not a `Bool`.",
1228 &["if_expr"],
1229 ),
1230 d(
1231 "bynk.types.interpolation_non_scalar",
1232 "An interpolation hole holds a value with no string form.",
1233 ),
1234 dg(
1235 "bynk.types.invalid_regex",
1236 "A `Matches` predicate contains an invalid regular expression.",
1237 &["refinement"],
1238 ),
1239 dg(
1240 "bynk.types.inverted_range",
1241 "An `InRange` predicate has its bounds inverted.",
1242 &["refinement"],
1243 ),
1244 dg(
1245 "bynk.types.is_base_mismatch",
1246 "An `is` refinement check is applied to a value of the wrong base type.",
1247 &["is_expr"],
1248 ),
1249 dg(
1250 "bynk.types.is_non_sum",
1251 "`is` was applied to a value that is not a sum type.",
1252 &["is_expr"],
1253 ),
1254 dg(
1255 "bynk.types.is_unknown_variant",
1256 "`is` names a variant the type does not have.",
1257 &["is_expr"],
1258 ),
1259 dg(
1260 "bynk.types.json_uncodable",
1261 "A `Json.encode`/`Json.decode` target type cannot pass through the typed JSON codec (functions, effects, error builtins).",
1262 &["method_call"],
1263 ),
1264 dg(
1265 "bynk.types.key_not_orderable",
1266 "A `sortBy`/`min`/`max` key function does not return an orderable type (`Int`, `Float`, `String`, `Duration`, or `Instant`).",
1267 &[],
1268 ),
1269 dg(
1270 "bynk.types.lambda_mismatch",
1271 "A lambda's parameter count, parameter annotations, or body type do not match the expected function type.",
1272 &["lambda_expr"],
1273 ),
1274 dg(
1275 "bynk.types.let_annotation_mismatch",
1276 "A `let` value does not match its type annotation.",
1277 &["let_stmt"],
1278 ),
1279 dg(
1280 "bynk.types.list_element_mismatch",
1281 "A list-literal element has a different type from the list's element type.",
1282 &["list_literal"],
1283 ),
1284 dg(
1285 "bynk.types.match_arm_mismatch",
1286 "A `match` arm has a different type from the others.",
1287 &["match_arm"],
1288 ),
1289 dg(
1290 "bynk.types.match_non_sum_discriminant",
1291 "`match` was applied to a value that is not a sum type.",
1292 &["match_expr"],
1293 ),
1294 dg(
1295 "bynk.types.method_arity",
1296 "A method was called with the wrong number of arguments.",
1297 &["method_call"],
1298 ),
1299 dg(
1300 "bynk.types.method_not_found",
1301 "Called a method the type does not have.",
1302 &["method_call"],
1303 ),
1304 dg(
1305 "bynk.types.method_on_non_named_type",
1306 "A method was called on a built-in type that has no methods.",
1307 &["method_call"],
1308 ),
1309 dg(
1310 "bynk.types.mixed_pattern_bindings",
1311 "A pattern mixes named and positional bindings.",
1312 &["variant_pattern"],
1313 ),
1314 dg(
1315 "bynk.types.negative_length",
1316 "A length predicate was given a negative value.",
1317 &["refinement"],
1318 ),
1319 dg(
1320 "bynk.types.no_numeric_coercion",
1321 "`Int` and `Float` were mixed without an explicit conversion — in an operation or in refinement bounds.",
1322 &["binary_expr", "refinement"],
1323 ),
1324 dg(
1325 "bynk.types.non_exhaustive_match",
1326 "A `match` does not cover every variant.",
1327 &["match_expr"],
1328 ),
1329 dg(
1330 "bynk.types.ok_value_mismatch",
1331 "An `Ok` payload has the wrong type.",
1332 &["ok_expr"],
1333 ),
1334 dg(
1335 "bynk.types.opaque_raw_outside",
1336 "`.raw` on an opaque type was used outside its defining commons.",
1337 &["field_access"],
1338 ),
1339 dg(
1340 "bynk.types.opaque_record_construction",
1341 "An opaque type was constructed with record syntax.",
1342 &["record_construction"],
1343 ),
1344 dg(
1345 "bynk.types.opaque_unsafe_outside",
1346 "`.unsafe` on an opaque type was used outside its defining context.",
1347 &["field_access"],
1348 ),
1349 dg(
1350 "bynk.types.pattern_arity",
1351 "A pattern binds the wrong number of payload fields.",
1352 &["variant_pattern"],
1353 ),
1354 dg(
1355 "bynk.types.pattern_type_mismatch",
1356 "A pattern's type does not match the matched value.",
1357 &["variant_pattern"],
1358 ),
1359 dg(
1360 "bynk.types.predicate_base_mismatch",
1361 "A predicate does not apply to the type's base (e.g. a string predicate on an `Int`).",
1362 &["refinement"],
1363 ),
1364 d(
1365 "bynk.types.query_at_boundary",
1366 "A `Query` type appears in a storable or boundary-crossing position — a query is built and executed in place, never persisted or sent (ADR 0115).",
1367 ),
1368 dg(
1369 "bynk.types.question_error_mismatch",
1370 "`?` propagates an error type incompatible with the function's.",
1371 &["question_expr"],
1372 ),
1373 dg(
1374 "bynk.types.question_on_non_result",
1375 "`?` was applied to a non-`Result` value.",
1376 &["question_expr"],
1377 ),
1378 dg(
1379 "bynk.types.question_outside_result",
1380 "`?` used in a function that does not return a `Result`.",
1381 &["question_expr"],
1382 ),
1383 d(
1384 "bynk.types.return_mismatch",
1385 "A returned value does not match the declared return type.",
1386 ),
1387 dg(
1388 "bynk.types.some_value_mismatch",
1389 "A `Some` payload has the wrong type.",
1390 &["some_expr"],
1391 ),
1392 d(
1393 "bynk.types.type_mismatch",
1394 "Two types that were required to match did not.",
1395 ),
1396 dg(
1397 "bynk.types.uninferable_element_type",
1398 "An empty `[]` (or `List.empty()` / `Map.empty()`) has no expected type to infer its element type from.",
1399 &["list_literal"],
1400 ),
1401 dg(
1402 "bynk.types.unkeyable_distinct",
1403 "A `distinct`/`distinctBy` element or key is not value-keyable (`String`, `Int`, or a refined/opaque type over them).",
1404 &[],
1405 ),
1406 dg(
1407 "bynk.types.unkeyable_map_key",
1408 "A `Map` key type is not value-keyable (`String`, `Int`, or a refined/opaque type over them).",
1409 &["generic_type_ref"],
1410 ),
1411 dg(
1412 "bynk.types.unknown_field",
1413 "Referenced a field the record type does not declare.",
1414 &["field_access"],
1415 ),
1416 dg(
1417 "bynk.types.unknown_pattern_field",
1418 "A pattern names a field the variant does not have.",
1419 &["variant_pattern"],
1420 ),
1421 dg(
1422 "bynk.types.unknown_static_member",
1423 "Referenced an unknown static member on a type.",
1424 &["field_access"],
1425 ),
1426 dg(
1427 "bynk.types.unknown_variant_in_pattern",
1428 "A pattern names a variant the sum type does not have.",
1429 &["variant_pattern"],
1430 ),
1431 dg(
1432 "bynk.types.unreachable_arm",
1433 "A `match` arm is unreachable.",
1434 &["match_arm"],
1435 ),
1436 d(
1437 "bynk.types.variant_arity",
1438 "A variant constructor got the wrong number of payload values.",
1439 ),
1440 d(
1441 "bynk.types.variant_missing_payload",
1442 "A variant requiring a payload was used without one.",
1443 ),
1444 d(
1445 "bynk.types.variant_payload_mismatch",
1446 "A variant payload has the wrong type.",
1447 ),
1448 dg(
1449 "bynk.uses.name_conflict",
1450 "A `uses` name collides with another name.",
1451 &["uses_decl"],
1452 ),
1453 dg(
1454 "bynk.uses.self_reference",
1455 "A commons `uses` itself.",
1456 &["uses_decl"],
1457 ),
1458 dg(
1459 "bynk.uses.target_is_context",
1460 "`uses` targets a context instead of a commons.",
1461 &["uses_decl"],
1462 ),
1463 dg(
1464 "bynk.uses.unknown_commons",
1465 "`uses` names a commons that does not exist.",
1466 &["uses_decl"],
1467 ),
1468];
1469
1470const fn d(code: &'static str, summary: &'static str) -> DiagnosticInfo {
1472 DiagnosticInfo {
1473 code,
1474 summary,
1475 grammar_symbol: &[],
1476 }
1477}
1478
1479const fn dg(
1481 code: &'static str,
1482 summary: &'static str,
1483 grammar_symbol: &'static [&'static str],
1484) -> DiagnosticInfo {
1485 DiagnosticInfo {
1486 code,
1487 summary,
1488 grammar_symbol,
1489 }
1490}
1491
1492pub fn category(code: &str) -> &str {
1495 code.split('.').nth(1).unwrap_or("")
1496}
1497
1498fn category_title(cat: &str) -> &'static str {
1500 match cat {
1501 "agent" | "agents" => "Agents",
1502 "assert" => "Assertions",
1503 "boundary" => "Boundaries",
1504 "capability" => "Capabilities",
1505 "consumes" => "Consumes",
1506 "context" => "Contexts",
1507 "cron" => "Cron",
1508 "effect" => "Effects",
1509 "exports" => "Exports",
1510 "given" => "Given capabilities",
1511 "http" => "HTTP",
1512 "lex" => "Lexer",
1513 "mock" => "Mock and mocks",
1514 "parse" => "Parser",
1515 "project" => "Project",
1516 "provider" => "Providers",
1517 "queue" => "Queue",
1518 "record_spread" => "Record spread",
1519 "refine" => "Refinement",
1520 "resolve" => "Resolution",
1521 "service" => "Services",
1522 "test" => "Tests",
1523 "types" => "Type checking",
1524 "uses" => "Uses",
1525 _ => "Other",
1526 }
1527}
1528
1529pub fn render_markdown() -> String {
1532 use std::collections::BTreeMap;
1533
1534 let mut by_category: BTreeMap<&str, Vec<&DiagnosticInfo>> = BTreeMap::new();
1536 for info in REGISTRY {
1537 by_category
1538 .entry(category_title(category(info.code)))
1539 .or_default()
1540 .push(info);
1541 }
1542
1543 let mut out = String::new();
1544 out.push_str("# Diagnostic index\n\n");
1545 out.push_str(
1546 "<!-- GENERATED FILE — do not edit by hand.\n \
1547 Source: bynkc/src/diagnostics.rs (`render_markdown`).\n \
1548 Regenerate with: BYNK_BLESS=1 cargo test -p bynkc --test diagnostics_registry -->\n\n",
1549 );
1550 out.push_str(
1551 "Every diagnostic code the compiler can emit, with a one-line summary of \
1552 the cause, grouped by category. For step-by-step cause-and-fix guidance \
1553 on the most common ones, see the [troubleshooting guides](../troubleshooting/index.md).\n\n",
1554 );
1555 out.push_str(&format!(
1556 "There are **{}** codes in total.\n",
1557 REGISTRY.len()
1558 ));
1559
1560 for (title, infos) in &by_category {
1561 out.push_str(&format!("\n## {title}\n\n"));
1562 out.push_str("| Code | Summary | Construct |\n|---|---|---|\n");
1563 for info in infos {
1564 let construct = info
1569 .grammar_symbol
1570 .iter()
1571 .map(|sym| format!("[`{sym}`](grammar.md#rule-{sym})"))
1572 .collect::<Vec<_>>()
1573 .join(", ");
1574 out.push_str(&format!(
1575 "| `{}` | {} | {} |\n",
1576 info.code, info.summary, construct
1577 ));
1578 }
1579 }
1580
1581 out
1582}
1583
1584pub fn render_grammar_semantics_json() -> String {
1590 use std::collections::BTreeMap;
1591
1592 let mut by_symbol: BTreeMap<&str, Vec<&DiagnosticInfo>> = BTreeMap::new();
1595 for info in REGISTRY {
1596 for sym in info.grammar_symbol {
1597 by_symbol.entry(sym).or_default().push(info);
1598 }
1599 }
1600
1601 let mut map = serde_json::Map::new();
1602 map.insert(
1603 "_generated".to_string(),
1604 serde_json::Value::String(
1605 "Generated from the grammar_symbol field of bynkc/src/diagnostics.rs. \
1606 Do not edit by hand. Regenerate with: BYNK_BLESS=1 cargo test -p \
1607 bynkc --test diagnostics_registry"
1608 .to_string(),
1609 ),
1610 );
1611 for (sym, infos) in by_symbol {
1612 let arr: Vec<serde_json::Value> = infos
1613 .iter()
1614 .map(|info| serde_json::json!({ "code": info.code, "summary": info.summary }))
1615 .collect();
1616 map.insert(sym.to_string(), serde_json::Value::Array(arr));
1617 }
1618
1619 let mut s =
1620 serde_json::to_string_pretty(&serde_json::Value::Object(map)).expect("serialise semantics");
1621 s.push('\n');
1622 s
1623}