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