Skip to main content

bynk_check/
shadow_uses.rs

1//! #1824: where a unit's own code meets an imported declaration's position
2//! that names a type the unit shadows.
3//!
4//! A unit's own `type Repo` shadows the `Repo` of a commons it `uses`
5//! directly (`compose_unit_symbols`: local first), and that stays legal:
6//! `1697_derived_names_collide` declares its own `Message` beside
7//! `uses bynk.locale.types`. But type names are bare strings to the checker,
8//! so an imported declaration that names `Repo` (`t.model`'s
9//! `type Run = { repo: Repo }`) is checked here against the *local* `Repo`.
10//! `Run { repo: 42 }` checks, and the emitted TypeScript, typed against
11//! `t.core`'s `Repo`, fails `tsc`.
12//!
13//! [`crate::project_model::close_reachable_types`] records each such reach
14//! ([`ShadowedReaches`]); this pass, run after a file's bodies are checked,
15//! reports `bynk.uses.name_conflict` where a value crosses between the unit's
16//! own code and one of those *shadowed positions*. A shadowed position is a
17//! position of an imported declaration whose declared type names a shadowed
18//! type, resolved in the declaring unit's scope:
19//!
20//! - a value goes **in** at a record field (`Run { repo: … }`, and the
21//!   overrides of `Run { ...r, repo: … }`), a fn, method or static parameter,
22//!   or a variant payload (`Text(…)`);
23//! - a value comes **out** of a field read (`r.repo`), a call's result, or a
24//!   payload a `match` arm or `is` test binds.
25//!
26//! A value that comes out of one shadowed position straight into another
27//! naming the same types never meets the unit's own code: both sides mean the
28//! imported type, in the checker and in the emitted TypeScript alike. That is
29//! 1697's `render(tag, message("greeting"))`, which stays legal. Every other
30//! crossing is a conflict, including one that goes through a `let` first:
31//! the rule reads the expression in the position, not where its value came
32//! from, so it errs towards rejecting.
33//!
34//! Not covered: a reference to an imported fn as a value (`list.map(f)`), and
35//! a payload bound by a nested pattern (`Some(Text(v))`). Test suites are
36//! checked by `crate::test_suites`, which does not run this pass.
37
38use std::collections::{HashMap, HashSet};
39use std::sync::Arc;
40
41use crate::checker::{Callee, Ty, TypedCommons};
42use crate::project_model::{ShadowedReaches, ShadowedType};
43use crate::resolver::MethodTable as ResolverMethodTable;
44use bynk_syntax::ast::*;
45use bynk_syntax::error::CompileError;
46use bynk_syntax::span::Span;
47
48/// The unit-level tables the pass resolves an imported declaration through.
49pub struct ShadowScope<'a> {
50    /// The unit being checked.
51    pub unit: &'a str,
52    pub shadowed: &'a ShadowedReaches,
53    pub combined_types: &'a HashMap<String, Arc<TypeDecl>>,
54    pub combined_fns: &'a HashMap<String, Arc<FnDecl>>,
55    pub combined_methods: &'a HashMap<String, ResolverMethodTable>,
56    pub imported_from: &'a HashMap<String, String>,
57}
58
59/// A shadowed position of an imported declaration: what it is called in a
60/// diagnostic, the unit that declares it, and the shadowed types it names.
61struct Position<'a> {
62    what: String,
63    declared_in: &'a str,
64    types: Vec<&'a ShadowedType>,
65}
66
67/// Report every crossing in `typed`'s bodies: fns and methods (with their
68/// contracts), service and agent handlers, agent invariants and transitions,
69/// and provider operations. Empty when no imported declaration reaches a
70/// shadowed type, which is the common case and costs one check.
71pub fn check_shadowed_uses(typed: &TypedCommons, scope: &ShadowScope<'_>) -> Vec<CompileError> {
72    if scope.shadowed.is_empty() {
73        return Vec::new();
74    }
75    let mut walk = Walk {
76        typed,
77        scope,
78        accepted: HashSet::new(),
79        errors: Vec::new(),
80    };
81    for item in &typed.commons.items {
82        match item {
83            CommonsItem::Fn(f) => {
84                walk.block(&f.body);
85                for c in f.requires.iter().chain(&f.ensures) {
86                    walk.expr(&c.predicate);
87                }
88            }
89            CommonsItem::Service(s) => {
90                for h in &s.handlers {
91                    walk.block(&h.body);
92                }
93            }
94            CommonsItem::Agent(a) => {
95                for h in &a.handlers {
96                    walk.block(&h.body);
97                }
98                for p in a
99                    .invariants
100                    .iter()
101                    .map(|i| &i.predicate)
102                    .chain(a.transitions.iter().map(|t| &t.predicate))
103                {
104                    walk.expr(p);
105                }
106            }
107            CommonsItem::Provider(p) => {
108                for op in &p.ops {
109                    walk.block(&op.body);
110                }
111            }
112            _ => {}
113        }
114    }
115    walk.errors
116}
117
118struct Walk<'a, 's> {
119    typed: &'a TypedCommons,
120    scope: &'a ShadowScope<'s>,
121    /// Values that come out of a shadowed position straight into one naming
122    /// the same types: not a crossing.
123    accepted: HashSet<ExprId>,
124    errors: Vec<CompileError>,
125}
126
127impl<'a, 's> Walk<'a, 's>
128where
129    's: 'a,
130{
131    fn block(&mut self, b: &Block) {
132        let mut exprs = Vec::new();
133        for s in &b.statements {
134            statement_exprs(s, &mut exprs);
135        }
136        exprs.push(&b.tail);
137        for e in exprs {
138            self.expr(e);
139        }
140    }
141
142    /// Pre-order, so a value an enclosing position accepts is marked before
143    /// the value itself is visited.
144    fn expr(&mut self, e: &Expr) {
145        match &e.kind {
146            ExprKind::Call { args, .. } | ExprKind::MethodCall { args, .. } => {
147                for (arg, pos) in self.params_of(e, args.len()) {
148                    if let Some(pos) = pos {
149                        self.value_in(&args[arg], args[arg].span, &pos);
150                    }
151                }
152            }
153            ExprKind::RecordConstruction {
154                type_name, fields, ..
155            } => {
156                self.field_inits(&type_name.name, fields);
157            }
158            ExprKind::RecordSpread {
159                type_name: Some(type_name),
160                overrides,
161                ..
162            } => {
163                self.field_inits(&type_name.name, overrides);
164            }
165            ExprKind::Match { discriminant, arms } => {
166                for arm in arms {
167                    self.pattern(discriminant, &arm.pattern);
168                }
169            }
170            ExprKind::Is { value, pattern } => self.pattern(value, pattern),
171            _ => {}
172        }
173        if !self.accepted.contains(&e.id)
174            && let Some(pos) = self.produced_by(e)
175        {
176            self.report(e.span, &pos, false);
177        }
178        for child in expr_children(e) {
179            self.expr(child);
180        }
181    }
182
183    /// A value going into a shadowed position.
184    fn value_in(&mut self, value: &Expr, span: Span, pos: &Position<'_>) {
185        let inner = peel(value);
186        if let Some(out) = self.produced_by(inner)
187            && out.types == pos.types
188        {
189            self.accepted.insert(inner.id);
190            self.accepted.insert(value.id);
191            return;
192        }
193        self.report(span, pos, true);
194    }
195
196    fn field_inits(&mut self, type_name: &str, fields: &[FieldInit]) {
197        let Some((decl, unit)) = self.imported_type(type_name) else {
198            return;
199        };
200        let TypeBody::Record(r) = &decl.body else {
201            return;
202        };
203        for init in fields {
204            let Some(field) = r.fields.iter().find(|f| f.name.name == init.name.name) else {
205                continue;
206            };
207            let Some(pos) = self.position(
208                format!("field `{type_name}.{}`", field.name.name),
209                unit,
210                &field.type_ref,
211                &decl.type_params,
212            ) else {
213                continue;
214            };
215            match &init.value {
216                Some(v) => self.value_in(v, v.span, &pos),
217                // Shorthand: the value is a local binding of the same name.
218                None => self.report(init.span, &pos, true),
219            }
220        }
221    }
222
223    /// A payload a top-level variant pattern binds, on a discriminant of an
224    /// imported sum type.
225    fn pattern(&mut self, discriminant: &Expr, pattern: &Pattern) {
226        match pattern {
227            Pattern::Or(alts, _) => {
228                for p in alts {
229                    self.pattern(discriminant, p);
230                }
231            }
232            Pattern::Variant {
233                variant, bindings, ..
234            } => {
235                let Some(name) = self.named_type_of(discriminant) else {
236                    return;
237                };
238                let Some((decl, unit)) = self.imported_type(&name) else {
239                    return;
240                };
241                let TypeBody::Sum(s) = &decl.body else {
242                    return;
243                };
244                let Some(v) = s.variants.iter().find(|v| v.name.name == variant.name) else {
245                    return;
246                };
247                for (i, b) in bindings.iter().enumerate() {
248                    if b.is_wildcard() {
249                        continue;
250                    }
251                    let field = match &b.kind {
252                        PatternBindingKind::Positional { .. } => v.payload.get(i),
253                        PatternBindingKind::Named { field, .. } => {
254                            v.payload.iter().find(|p| p.name.name == field.name)
255                        }
256                    };
257                    let Some(field) = field else {
258                        continue;
259                    };
260                    if let Some(pos) = self.position(
261                        format!("payload `{}` of `{name}.{}`", field.name.name, v.name.name),
262                        unit,
263                        &field.type_ref,
264                        &decl.type_params,
265                    ) {
266                        self.report(b.span, &pos, false);
267                    }
268                }
269            }
270            _ => {}
271        }
272    }
273
274    /// The shadowed position `e` reads a value out of, if any: a field of an
275    /// imported record, or an imported call's result.
276    fn produced_by(&self, e: &Expr) -> Option<Position<'s>> {
277        match &e.kind {
278            ExprKind::FieldAccess { receiver, field } => {
279                let name = self.named_type_of(receiver)?;
280                let (decl, unit) = self.imported_type(&name)?;
281                let TypeBody::Record(r) = &decl.body else {
282                    return None;
283                };
284                let f = r.fields.iter().find(|f| f.name.name == field.name)?;
285                self.position(
286                    format!("field `{name}.{}`", f.name.name),
287                    unit,
288                    &f.type_ref,
289                    &decl.type_params,
290                )
291            }
292            ExprKind::Call { .. } | ExprKind::MethodCall { .. } => {
293                let (f, unit, vars) = self.imported_fn(e)?;
294                self.position(
295                    format!("the result of `{}`", fn_display(f)),
296                    unit,
297                    &f.return_type,
298                    &vars,
299                )
300            }
301            // #2617: an imported constant, typed by its annotation in the
302            // declaring unit's scope.
303            ExprKind::Ident(id) => {
304                let c = self.typed.consts.get(&id.name)?;
305                let unit = self.scope.imported_from.get(&id.name)?;
306                if unit == self.scope.unit {
307                    return None;
308                }
309                self.position(format!("constant `{}`", id.name), unit, &c.ty, &[])
310            }
311            _ => None,
312        }
313    }
314
315    /// Each argument of the call `e` paired with its parameter's shadowed
316    /// position, if the callee is an imported declaration and the parameter
317    /// is one.
318    fn params_of(&self, e: &Expr, arity: usize) -> Vec<(usize, Option<Position<'s>>)> {
319        if let Some((f, unit, vars)) = self.imported_fn(e) {
320            // `params` holds no `self` (the parser keeps it as `has_self`),
321            // so a method's arguments line up with them one to one (#1879
322            // review).
323            return f
324                .params
325                .iter()
326                .take(arity)
327                .enumerate()
328                .map(|(i, p)| {
329                    let what = format!("parameter `{}` of `{}`", p.name.name, fn_display(f));
330                    (i, self.position(what, unit, &p.type_ref, &vars))
331                })
332                .collect();
333        }
334        if let Some(Callee::Ctor { sum, tag }) = self.typed.callee(e.id)
335            && let Some((decl, unit)) = self.imported_type(&sum.name.name)
336            && decl.span == sum.span
337            && let TypeBody::Sum(s) = &decl.body
338            && let Some(v) = s.variants.iter().find(|v| &v.name.name == tag)
339        {
340            return v
341                .payload
342                .iter()
343                .take(arity)
344                .enumerate()
345                .map(|(i, p)| {
346                    let what = format!(
347                        "payload `{}` of `{}.{}`",
348                        p.name.name, decl.name.name, v.name.name
349                    );
350                    (i, self.position(what, unit, &p.type_ref, &decl.type_params))
351                })
352                .collect();
353        }
354        Vec::new()
355    }
356
357    /// The imported fn, method or static the call `e` dispatched to, with its
358    /// declaring unit and the type variables its signature binds.
359    fn imported_fn(&self, e: &Expr) -> Option<(&'s FnDecl, &'s str, Vec<TypeParam>)> {
360        let sc = self.scope;
361        match self.typed.callee(e.id)? {
362            Callee::Fn(f, _) => {
363                let FnName::Free(n) = &f.name else {
364                    return None;
365                };
366                // The bundle's own `render` declares `bynk.locale`'s signature
367                // (1697's `render(tag, message("greeting"))`).
368                if crate::symbols::is_synthetic_render(f) {
369                    let decl = sc.combined_fns.get(&n.name)?;
370                    return Some((decl.as_ref(), "bynk.locale", Vec::new()));
371                }
372                let unit = sc.imported_from.get(&n.name)?;
373                let decl = sc.combined_fns.get(&n.name)?;
374                (decl.span == f.span)
375                    .then(|| (decl.as_ref(), unit.as_str(), decl.type_params.clone()))
376            }
377            Callee::Method(f, _) | Callee::Static(f, _) => {
378                let FnName::Method {
379                    type_name,
380                    method_name,
381                } = &f.name
382                else {
383                    return None;
384                };
385                let unit = sc.imported_from.get(&type_name.name)?;
386                let table = sc.combined_methods.get(&type_name.name)?;
387                let decl = table
388                    .instance
389                    .get(&method_name.name)
390                    .into_iter()
391                    .chain(table.statics.get(&method_name.name))
392                    .find(|d| d.span == f.span)?;
393                let mut vars = decl.type_params.clone();
394                if let Some(t) = sc.combined_types.get(&type_name.name) {
395                    vars.extend(t.type_params.iter().cloned());
396                }
397                Some((decl.as_ref(), unit.as_str(), vars))
398            }
399            _ => None,
400        }
401    }
402
403    /// An imported type declaration by name, with its declaring unit. A local
404    /// declaration of the name is not imported.
405    fn imported_type(&self, name: &str) -> Option<(&'s TypeDecl, &'s str)> {
406        let unit = self.scope.imported_from.get(name)?;
407        let decl = self.scope.combined_types.get(name)?;
408        Some((decl.as_ref(), unit.as_str()))
409    }
410
411    /// The name of the declared type `e` was checked as, if it is one.
412    fn named_type_of(&self, e: &Expr) -> Option<String> {
413        match &*self.typed.expr_ty(e.id)? {
414            Ty::Named { name, .. } => Some(name.clone()),
415            _ => None,
416        }
417    }
418
419    /// `r` as a shadowed position, when it names a shadowed type in `unit`'s
420    /// scope.
421    fn position(
422        &self,
423        what: String,
424        unit: &'s str,
425        r: &TypeRef,
426        vars: &[TypeParam],
427    ) -> Option<Position<'s>> {
428        let types = self.scope.shadowed.in_type_ref(unit, r, vars);
429        (!types.is_empty()).then_some(Position {
430            what,
431            declared_in: unit,
432            types,
433        })
434    }
435
436    fn report(&mut self, span: Span, pos: &Position<'_>, into: bool) {
437        let t = pos.types[0];
438        let here = self.scope.unit;
439        let verb = if into { "takes" } else { "gives" };
440        let shadow = if t.bound == here {
441            format!("`{here}` declares its own `{}`", t.name)
442        } else {
443            format!("`{}` here names `{}`'s declaration", t.name, t.bound)
444        };
445        self.errors.push(
446            CompileError::new(
447                "bynk.uses.name_conflict",
448                span,
449                format!(
450                    "{what} from `{decl}` {verb} `{owner}`'s `{name}`, but `{name}` in `{here}` \
451                     names `{bound}`'s type",
452                    what = pos.what,
453                    decl = pos.declared_in,
454                    owner = t.owner,
455                    name = t.name,
456                    bound = t.bound,
457                ),
458            )
459            .with_note(format!(
460                "{shadow}, which shadows `{owner}`'s; a value that crosses here cannot be \
461                 checked against both, so rename one of the two types",
462                owner = t.owner,
463            )),
464        );
465    }
466}
467
468/// An argument without its parentheses, which carry no value of their own.
469fn peel(e: &Expr) -> &Expr {
470    match &e.kind {
471        ExprKind::Paren(inner) => peel(inner),
472        _ => e,
473    }
474}
475
476fn fn_display(f: &FnDecl) -> String {
477    match &f.name {
478        FnName::Free(n) => n.name.clone(),
479        FnName::Method {
480            type_name,
481            method_name,
482        } => format!("{}.{}", type_name.name, method_name.name),
483    }
484}
485
486#[cfg(test)]
487mod tests {
488    use crate::testkit::analyse;
489
490    const CORE: &str = "commons t.core\n\ntype Repo = String where NonEmpty\n\n\
491                        type Tag = | Named(value: Repo) | Anon\n";
492    const MODEL: &str = "commons t.model\n\nuses t.core\n\n\
493                         type Run = { repo: Repo, n: Int }\n\n\
494                         fn keep(r: Repo) -> Repo { r }\n\n\
495                         fn first(r: Run) -> Repo { r.repo }\n\n\
496                         fn count(r: Run) -> Int { r.n }\n\n\
497                         fn Run.repoOf(self) -> Repo { self.repo }\n\n\
498                         fn Run.withRepo(self, repo: Repo, k: Int) -> Run { Run { repo: repo, n: k } }\n\n\
499                         fn Run.make(repo: Repo) -> Run { Run { repo: repo, n: 0 } }\n";
500
501    /// The `bynk.uses.name_conflict` messages for a `t.app` that shadows
502    /// `t.core`'s `Repo` and declares `body`. Any other error fails the test.
503    fn conflicts(body: &str) -> Vec<String> {
504        let app =
505            format!("commons t.app\n\nuses t.core\nuses t.model\n\ntype Repo = Int\n\n{body}\n");
506        let a = analyse(&[
507            ("t/core.bynk", CORE),
508            ("t/model.bynk", MODEL),
509            ("t/app.bynk", &app),
510        ]);
511        let other: Vec<_> = a
512            .error_categories()
513            .into_iter()
514            .filter(|c| *c != "bynk.uses.name_conflict")
515            .collect();
516        assert!(other.is_empty(), "unexpected diagnostics:\n{}", a.render());
517        a.analysis
518            .errors
519            .iter()
520            .filter(|e| e.error.category == "bynk.uses.name_conflict")
521            .map(|e| e.error.message.clone())
522            .collect()
523    }
524
525    fn assert_one(body: &str, what: &str) {
526        let got = conflicts(body);
527        assert!(
528            got.len() == 1 && got[0].starts_with(what),
529            "expected one conflict at {what}, got {got:#?}"
530        );
531    }
532
533    #[test]
534    fn a_shadow_the_code_never_meets_is_legal() {
535        assert_eq!(
536            conflicts("fn size(r: Run) -> Int { r.n }\n\nfn mine() -> Repo { 7 }"),
537            Vec::<String>::new()
538        );
539    }
540
541    #[test]
542    fn a_value_moved_between_imported_positions_is_legal() {
543        assert_eq!(
544            conflicts(
545                "fn retag(r: Run) -> Int { count(Run { repo: keep((r.repo)), n: 1 }) }\n\n\
546                 fn again(r: Run) -> Run { Run { repo: first(r), n: 2 } }"
547            ),
548            Vec::<String>::new()
549        );
550    }
551
552    #[test]
553    fn a_local_value_into_a_record_field_conflicts() {
554        assert_one(
555            "fn make() -> Run { Run { repo: 42, n: 1 } }",
556            "field `Run.repo` from `t.model` takes `t.core`'s `Repo`",
557        );
558    }
559
560    #[test]
561    fn a_shorthand_field_conflicts() {
562        assert_one(
563            "fn make(repo: Repo) -> Run { Run { repo, n: 1 } }",
564            "field `Run.repo` from `t.model` takes",
565        );
566    }
567
568    #[test]
569    fn a_field_read_into_local_code_conflicts() {
570        assert_one(
571            "fn read(r: Run) -> Int { r.repo + 1 }",
572            "field `Run.repo` from `t.model` gives `t.core`'s `Repo`",
573        );
574    }
575
576    #[test]
577    fn a_call_result_into_local_code_conflicts() {
578        assert_one(
579            "fn read(r: Run) -> Int { first(r) }",
580            "the result of `first` from `t.model` gives",
581        );
582    }
583
584    #[test]
585    fn a_method_result_into_local_code_conflicts() {
586        assert_one(
587            "fn read(r: Run) -> Int { r.repoOf() }",
588            "the result of `Run.repoOf` from `t.model` gives",
589        );
590    }
591
592    #[test]
593    fn a_local_argument_conflicts() {
594        assert_one(
595            "fn pass(x: Repo) -> Int { count(Run { repo: keep(x), n: 1 }) }",
596            "parameter `r` of `keep` from `t.model` takes",
597        );
598    }
599
600    #[test]
601    fn a_value_through_a_let_conflicts() {
602        // The rule reads the expression in the position, not where its value
603        // came from: both ends of the `let` are crossings.
604        let got = conflicts(
605            "fn via(r: Run) -> Int {\n  let x = first(r)\n  count(Run { repo: x, n: 1 })\n}",
606        );
607        assert_eq!(got.len(), 2, "{got:#?}");
608    }
609
610    #[test]
611    fn a_bound_payload_conflicts() {
612        assert_one(
613            "fn tag(t: Tag) -> Int {\n  match t {\n    Named(v) => 1,\n    Anon => 0,\n  }\n}",
614            "payload `value` of `Tag.Named` from `t.core` gives",
615        );
616    }
617
618    #[test]
619    fn a_discarded_payload_is_legal() {
620        assert_eq!(
621            conflicts(
622                "fn tag(t: Tag) -> Int {\n  match t {\n    Named(_) => 1,\n    Anon => 0,\n  }\n}"
623            ),
624            Vec::<String>::new()
625        );
626    }
627
628    #[test]
629    fn a_local_payload_conflicts() {
630        assert_one(
631            "fn tag() -> Tag { Named(5) }",
632            "payload `value` of `Tag.Named` from `t.core` takes",
633        );
634    }
635
636    /// #1879 review: a method's explicit parameters line up with its
637    /// arguments (`params` holds no `self`), so the first is checked too.
638    #[test]
639    fn a_method_parameter_is_checked() {
640        let got = conflicts("fn re(r: Run) -> Run { r.withRepo(42, 1) }");
641        assert!(
642            got.len() == 1 && got[0].contains("parameter `repo`"),
643            "expected one conflict at `repo`, got {got:#?}"
644        );
645    }
646
647    #[test]
648    fn a_static_parameter_is_checked() {
649        let got = conflicts("fn mk() -> Run { Run.make(42) }");
650        assert!(
651            got.len() == 1 && got[0].contains("parameter `repo`"),
652            "expected one conflict at `repo`, got {got:#?}"
653        );
654    }
655
656    #[test]
657    fn a_handler_body_is_checked() {
658        let a = analyse(&[
659            ("t/core.bynk", CORE),
660            ("t/model.bynk", MODEL),
661            (
662                "src/t/web.bynk",
663                "context t.web\n\nuses t.core\nuses t.model\n\ntype Repo = Int\n\n\
664                 service read {\n  on call(r: Run) -> Effect[Int] by Caller {\n    r.repo + 1\n  }\n}\n",
665            ),
666        ]);
667        a.assert_reports("bynk.uses.name_conflict");
668    }
669
670    /// #1879 review: provider operations and agent handlers are walked too.
671    #[test]
672    fn provider_ops_and_agent_handlers_are_checked() {
673        for (name, body) in [
674            (
675                "provider op",
676                "capability Reader {\n  fn read(r: Run) -> Effect[Int]\n}\n\n\
677                 provides Reader = Plain {\n  fn read(r: Run) -> Effect[Int] {\n    r.repo + 1\n  }\n}\n",
678            ),
679            (
680                "agent handler",
681                "agent Holder {\n  key id: String\n\n  store hits: Cell[Int]\n\n  \
682                 on call read(r: Run) -> Effect[Int] {\n    r.repo + 1\n  }\n}\n",
683            ),
684        ] {
685            let src =
686                format!("context t.web\n\nuses t.core\nuses t.model\n\ntype Repo = Int\n\n{body}");
687            let a = analyse(&[
688                ("t/core.bynk", CORE),
689                ("t/model.bynk", MODEL),
690                ("src/t/web.bynk", &src),
691            ]);
692            assert!(
693                a.error_categories().contains(&"bynk.uses.name_conflict"),
694                "{name}: expected a conflict:\n{}",
695                a.render()
696            );
697        }
698    }
699}