Skip to content

Commit

Permalink
Handle error context when inferring multiplicity and cardinality..
Browse files Browse the repository at this point in the history
  • Loading branch information
dnwpark committed May 31, 2024
1 parent 542ebb1 commit 7377855
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions edb/edgeql/compiler/inference/cardinality.py
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,11 @@ def __infer_typecast(
scope_tree: irast.ScopeTreeNode,
ctx: inference_context.InfCtx,
) -> qltypes.Cardinality:
if ir.error_message_context is not None:
infer_cardinality(
ir.error_message_context, scope_tree=scope_tree, ctx=ctx
)

card = infer_cardinality(
ir.expr, scope_tree=scope_tree, ctx=ctx,
)
Expand Down
5 changes: 5 additions & 0 deletions edb/edgeql/compiler/inference/multiplicity.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,11 @@ def __infer_typecast(
scope_tree: irast.ScopeTreeNode,
ctx: inf_ctx.InfCtx,
) -> inf_ctx.MultiplicityInfo:
if ir.error_message_context is not None:
infer_multiplicity(
ir.error_message_context, scope_tree=scope_tree, ctx=ctx
)

return infer_multiplicity(
ir.expr, scope_tree=scope_tree, ctx=ctx,
)
Expand Down
5 changes: 1 addition & 4 deletions edb/edgeql/compiler/stmtctx.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

from edb.edgeql import ast as qlast

from edb.common.ast import visitor as ast_visitor, find_children
from edb.common.ast import visitor as ast_visitor
from edb.common import ordered
from edb.common.typeutils import not_none

Expand Down Expand Up @@ -191,9 +191,6 @@ def fini_expression(
if p.sub_params and p.sub_params.decoder_ir
]
extra_exprs += [trigger.expr for stage in ir_triggers for trigger in stage]
for type_cast in find_children(ir, irast.TypeCast):
if type_cast.error_message_context is not None:
extra_exprs.append(type_cast.error_message_context)

all_exprs = [ir] + extra_exprs

Expand Down

0 comments on commit 7377855

Please sign in to comment.