Repository: edgedb/edgedb

Issue:
InternalServerError: maximum recursion depth exceeded in comparison
- EdgeDB Version: 2.0-dev.6578+local

Steps to Reproduce:

```edgeql
SELECT default::Comment {
  issue := assert_exists((SELECT .issue {
    references := (SELECT .references LIMIT 1),
    priority := (SELECT .priority LIMIT 1),
    related_to := (SELECT .related_to LIMIT 1),
    status := (SELECT .status LIMIT 1),
    owner := (SELECT .owner LIMIT 1),
    time_spent_log := (SELECT .time_spent_log LIMIT 1),
    watchers := (SELECT .watchers LIMIT 1),
  } LIMIT 10)),
}

# InternalServerError: maximum recursion depth exceeded in comparison
```

Schema: https://github.com/edgedb/edgedb/blob/master/tests/schemas/issues.esdl



Discussion:
I can't reproduce this; can you share some of the backtrace also?
It seems the error only occurs for me when using the web ui (It works in the cli).

<details>
<summary>Backtrace:</summary>
<pre>
---- Exception occurred: maximum recursion depth exceeded in comparison ----

1. RecursionError: maximum recursion depth exceeded in comparison

---- Traceback ----

    /home/james/dev/edgedb/edb/server/compiler_pool/worker.py, line 158, in compile
        > units, cstate = COMPILER.compile(
    /home/james/dev/edgedb/edb/server/compiler/compiler.py, line 2142, in compile
        > units = self._compile(ctx=ctx, source=source)
    /home/james/dev/edgedb/edb/server/compiler/compiler.py, line 1694, in _compile
        > return self._try_compile(ctx=ctx, source=source)
    /home/james/dev/edgedb/edb/server/compiler/compiler.py, line 1747, in _try_compile
        > comp, capabilities = self._compile_dispatch_ql(
    /home/james/dev/edgedb/edb/server/compiler/compiler.py, line 1668, in _compile_dispatch_ql
        > query = self._compile_ql_query(ctx, ql)
    /home/james/dev/edgedb/edb/server/compiler/compiler.py, line 575, in _compile_ql_query
        > ir = qlcompiler.compile_ast_to_ir(
    /home/james/dev/edgedb/edb/edgeql/compiler/__init__.py, line 179, in wrapper
        > return func(*args, **kwargs)
    /home/james/dev/edgedb/edb/edgeql/compiler/__init__.py, line 232, in compile_ast_to_ir
        > ir_expr = stmtctx_mod.fini_expression(ir_set, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/stmtctx.py, line 139, in fini_expression
        > cardinality = inference.infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 524, in _infer_set_inner
        > expr_card = infer_cardinality(ir.expr, scope_tree=new_scope, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 508, in _infer_set
        > _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 489, in _infer_shape
        > _infer_shape(shape_set, is_mutation=is_mutation, scope_tree=scope_tree,
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 476, in _infer_shape
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 529, in _infer_set_inner
        > source_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 538, in _infer_set_inner
        > _infer_pointer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 337, in _infer_pointer_cardinality
        > expr_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1355, in infer_cardinality
        > result = _infer_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /usr/lib/python3.10/functools.py, line 889, in wrapper
        > return dispatch(args[0].__class__)(*args, **kw)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1156, in __infer_select_stmt
        > stmt_card = _infer_stmt_cardinality(ir, scope_tree=scope_tree, ctx=ctx)
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1096, in _infer_stmt_cardinality
        > result_card = infer_cardinality(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 1351, in infer_cardinality
        > result = _infer_set(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 500, in _infer_set
        > result = _infer_set_inner(
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/cardinality.py, line 552, in _infer_set_inner
        > if (node := inf_utils.find_visible(ir, scope_tree)) is not None:
    /home/james/dev/edgedb/edb/edgeql/compiler/inference/utils.py, line 64, in find_visible
        > return outer_fence.find_visible(path_id)
    /home/james/dev/edgedb/edb/ir/scopetree.py, line 772, in find_visible
        > node, _, _ = self.find_visible_ex(path_id, allow_group=allow_group)
    /home/james/dev/edgedb/edb/ir/scopetree.py, line 740, in find_visible_ex
        > and _paths_equal(child.path_id, path_id, namespaces)):
    /home/james/dev/edgedb/edb/ir/scopetree.py, line 1009, in _paths_equal
        > return path_id_1 == path_id_2
    /home/james/dev/edgedb/edb/ir/pathid.py, line 264, in __eq__
        > self._norm_path == other._norm_path and

RecursionError: maximum recursion depth exceeded in comparison
---- Exception occurred: maximum recursion depth exceeded in comparison ----

1. RecursionError: maximum recursion depth exceeded in comparison

---- Traceback ----

    edb/server/protocol/binary.pyx, line 1922, in edb.server.protocol.binary.EdgeConnection.main
        > await self.parse()
    edb/server/protocol/binary.pyx, line 1497, in parse
        > compiled_query = await self._parse(eql, query_req)
    edb/server/protocol/binary.pyx, line 1315, in _parse
        > query_unit = await self._compile(
    edb/server/protocol/binary.pyx, line 941, in _compile
        > result = await compiler_pool.compile(
    /home/james/dev/edgedb/edb/server/compiler_pool/pool.py, line 387, in compile
        > result = await worker.call(
    /home/james/dev/edgedb/edb/server/compiler_pool/pool.py, line 123, in call
        > raise exc

RecursionError: maximum recursion depth exceeded in comparison
ERROR 2335 2022-05-17T12:35:34.179 asyncio: an error in edgedb protocol
protocol: <edb.server.protocol.binary.EdgeConnection object at 0x7f69baf1db40>
transport: <edb.server.protocol.binary.VirtualTransport object at 0x7f69bad048e0>
</pre>
</details>
Aha, it looks like it happens when both type names *and* type ids are being injected, but not if only type names are being injected!
Alright, so this is a "legitimate" stack overflow, in the sense that it is not an *infinite* recursion. 

```
SELECT Comment {                                                         
  issue := assert_exists(( .issue {                                      
    status1 := ( .status ),                                              
    status2 := ( .status ),                                              
    status3 := ( .status ),                                              
    status4 := ( .status ),                                              
    status5 := ( .status ),                                              
    status6 := ( .status ),                                              
    status7 := ( .status ),                                              
  })),                                                                   
};
```
is a reduce version. Only going up to `status6` fixes it.

That said, something is pretty deeply wrong with cardinality inference in this case, though.

If I drop it down to 6 links, it compiles and generates the correct code, but it logs a whopping 18k calls to `_infer_pointer_cardinality`. 
I think that the "optimal" number of calls to `_infer_pointer_cardinality` here would be 29, though because of various things I'd really expect it to be some small integer multiple of that. Less than 100!

Resolving patch:
diff --git a/edb/edgeql/compiler/inference/cardinality.py b/edb/edgeql/compiler/inference/cardinality.py
--- a/edb/edgeql/compiler/inference/cardinality.py
+++ b/edb/edgeql/compiler/inference/cardinality.py
@@ -497,17 +497,34 @@ def _infer_set(
     scope_tree: irast.ScopeTreeNode,
     ctx: inference_context.InfCtx,
 ) -> qltypes.Cardinality:
-    result = _infer_set_inner(
-        ir, is_mutation=is_mutation,
-        scope_tree=scope_tree, ctx=ctx)
 
-    # We need to cache the main result before doing the shape,
-    # since sometimes the shape will refer to the enclosing set.
-    ctx.inferred_cardinality[ir, scope_tree, ctx.singletons] = result
+    # First compute (or look up) the "intrinsic" cardinality of the set
+    if not (result := ctx.inferred_cardinality.get(ir)):
+        result = _infer_set_inner(
+            ir, is_mutation=is_mutation,
+            scope_tree=scope_tree, ctx=ctx)
 
-    _infer_shape(ir, is_mutation=is_mutation, scope_tree=scope_tree, ctx=ctx)
+        # We need to cache the main result before doing the shape,
+        # since sometimes the shape will refer to the enclosing set.
+        ctx.inferred_cardinality[ir] = result
 
-    return result
+        new_scope = inf_utils.get_set_scope(ir, scope_tree, ctx=ctx)
+        _infer_shape(
+            ir, is_mutation=is_mutation, scope_tree=new_scope, ctx=ctx)
+
+    # With that in hand, compute the cardinality of a *reference* to the
+    # set from this location in the tree.
+    if ir.path_id in ctx.singletons:
+        return ONE
+    elif (node := inf_utils.find_visible(ir, scope_tree)) is not None:
+        if not node.optional:
+            return ONE
+        # If the set is visible, but optional, it must have upper bound ONE
+        # but we still want to compute the lower bound.
+        else:
+            return _bounds_to_card(_card_to_bounds(result).lower, CB_ONE)
+    else:
+        return result
 
 
 def _infer_set_inner(
@@ -545,17 +562,6 @@ def _infer_set_inner(
 
     # We have now inferred all of the subtrees we need to, so it is
     # safe to return.
-
-    if ir.path_id in ctx.singletons:
-        return ONE
-    force_single = False
-    if (node := inf_utils.find_visible(ir, scope_tree)) is not None:
-        if not node.optional:
-            return ONE
-        # If the set is visible, but optional, it must have upper bound ONE
-        # but we still want to compute the lower bound.
-        force_single = True
-
     if rptr is not None:
         if isinstance(rptrref, irast.TypeIntersectionPointerRef):
             ind_prefix, ind_ptrs = irutils.collapse_type_intersection(ir)
@@ -564,7 +570,7 @@ def _infer_set_inner(
                 # so this will just hit the cache and so it is OK for us to
                 # be doing it conditionally.
                 prefix_card = infer_cardinality(
-                    ind_prefix, scope_tree=new_scope, ctx=ctx,
+                    ind_prefix, scope_tree=scope_tree, ctx=ctx,
                 )
 
                 card = cartesian_cardinality([prefix_card, AT_MOST_ONE])
@@ -595,7 +601,7 @@ def _infer_set_inner(
                         # Already inferred, should just be hitting cache.
                         source_card = infer_cardinality(
                             ind_prefix.rptr.source,
-                            scope_tree=new_scope, ctx=ctx,
+                            scope_tree=scope_tree, ctx=ctx,
                         )
 
                     # The resulting cardinality is the cartesian
@@ -615,8 +621,7 @@ def _infer_set_inner(
                     for c in rptrref.union_components
                 )
             elif ctx.ignore_computed_cards and ir.expr:
-                rptrref_card = infer_cardinality(
-                    ir.expr, scope_tree=scope_tree, ctx=ctx)
+                rptrref_card = expr_card
             else:
                 rptrref_card = rptrref.dir_cardinality(rptr.direction)
 
@@ -634,9 +639,6 @@ def _infer_set_inner(
     else:
         card = MANY
 
-    if force_single:
-        card = _bounds_to_card(_card_to_bounds(card).lower, CB_ONE)
-
     # If this node is an optional argument bound at this location,
     # but it can't actually be zero, clear the optionality to avoid
     # subpar codegen.
@@ -1343,7 +1345,8 @@ def infer_cardinality(
     scope_tree: irast.ScopeTreeNode,
     ctx: inference_context.InfCtx,
 ) -> qltypes.Cardinality:
-    result = ctx.inferred_cardinality.get((ir, scope_tree, ctx.singletons))
+    key = (ir, scope_tree, ctx.singletons)
+    result = ctx.inferred_cardinality.get(key)
     if result is not None:
         return result
 
@@ -1360,7 +1363,7 @@ def infer_cardinality(
             'set produced by expression',
             context=ir.context)
 
-    ctx.inferred_cardinality[ir, scope_tree, ctx.singletons] = result
+    ctx.inferred_cardinality[key] = result
 
     return result
 
diff --git a/edb/edgeql/compiler/inference/context.py b/edb/edgeql/compiler/inference/context.py
--- a/edb/edgeql/compiler/inference/context.py
+++ b/edb/edgeql/compiler/inference/context.py
@@ -54,7 +54,10 @@ def is_zero(self) -> bool:
 class InfCtx(NamedTuple):
     env: context.Environment
     inferred_cardinality: Dict[
-        Tuple[irast.Base, irast.ScopeTreeNode, FrozenSet[irast.PathId]],
+        Union[
+            Tuple[irast.Base, irast.ScopeTreeNode, FrozenSet[irast.PathId]],
+            irast.Base,
+        ],
         qltypes.Cardinality,
     ]
     inferred_multiplicity: Dict[


Test patch:
diff --git a/tests/test_edgeql_select.py b/tests/test_edgeql_select.py
--- a/tests/test_edgeql_select.py
+++ b/tests/test_edgeql_select.py
@@ -7284,3 +7284,20 @@ async def test_edgeql_select_free_object_distinct_03(self):
             for x in {1,2,3} union w
         ''')
         self.assertEqual(1, len({v.id for v in vals}))
+
+    async def test_edgeql_select_card_blowup_01(self):
+        # This used to really blow up cardinality inference
+        await self.con.query('''
+        SELECT Comment {
+          issue := assert_exists(( .issue {
+            status1 := ( .status { a := .__type__.name, b := .__type__.id } ),
+            status2 := ( .status { a := .__type__.name, b := .__type__.id } ),
+            status3 := ( .status { a := .__type__.name, b := .__type__.id } ),
+            status4 := ( .status { a := .__type__.name, b := .__type__.id } ),
+            status5 := ( .status { a := .__type__.name, b := .__type__.id } ),
+            status6 := ( .status { a := .__type__.name, b := .__type__.id } ),
+            status7 := ( .status { a := .__type__.name, b := .__type__.id } ),
+            status8 := ( .status { a := .__type__.name, b := .__type__.id } ),
+          })),
+        };
+        ''')