Skip to content

Commit

Permalink
Drop explicit use of EmptySet as a dummy set (#7093)
Browse files Browse the repository at this point in the history
Instead declare a DUMMY_SET in irast. This generally seems cleaner and
helps prepare for eliminating EmptySet as part of the IR refactors.
  • Loading branch information
msullivan authored and vpetrovykh committed Apr 10, 2024
1 parent ea572c5 commit e0d869b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion edb/edgeql/compiler/casts.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ def _find_cast(
else:
return None

dummy_set = irast.EmptySet() # type: ignore
dummy_set = irast.DUMMY_SET
args = [
(orig_stype, dummy_set),
(new_stype, dummy_set),
Expand Down
2 changes: 1 addition & 1 deletion edb/edgeql/compiler/polyres.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def find_callable_typemods(
"""

typ = s_pseudo.PseudoType.get(ctx.env.schema, 'anytype')
dummy = irast.EmptySet() # type: ignore
dummy = irast.DUMMY_SET
args = [(typ, dummy)] * num_args
kwargs = {k: (typ, dummy) for k in kwargs_names}
options = find_callable(
Expand Down
17 changes: 10 additions & 7 deletions edb/ir/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,9 @@ def __repr__(self) -> str:
Set = SetE


DUMMY_SET = Set() # type: ignore[call-arg]


class Command(Base):
__abstract_node__ = True

Expand Down Expand Up @@ -1115,8 +1118,8 @@ class Stmt(Expr):
name: typing.Optional[str] = None
# Parts of the edgeql->IR compiler need to create statements and fill in
# the result later, but making it Optional would cause lots of errors,
# so we stick a bogus Empty set in.
result: Set = EmptySet() # type: ignore
# so we stick a dummy set set in.
result: Set = DUMMY_SET
parent_stmt: typing.Optional[Stmt] = None
iterator_stmt: typing.Optional[Set] = None
bindings: typing.Optional[typing.List[Set]] = None
Expand Down Expand Up @@ -1147,12 +1150,12 @@ class SelectStmt(FilteredStmt):


class GroupStmt(FilteredStmt):
subject: Set = EmptySet() # type: ignore
subject: Set = DUMMY_SET
using: typing.Dict[str, typing.Tuple[Set, qltypes.Cardinality]] = (
ast.field(factory=dict))
by: typing.List[qlast.GroupingElement]
result: Set = EmptySet() # type: ignore
group_binding: Set = EmptySet() # type: ignore
result: Set = DUMMY_SET
group_binding: Set = DUMMY_SET
grouping_binding: typing.Optional[Set] = None
orderby: typing.Optional[typing.List[SortExpr]] = None
# Optimization information
Expand Down Expand Up @@ -1187,8 +1190,8 @@ class MutatingStmt(Stmt, MutatingLikeStmt):
__abstract_node__ = True
# Parts of the edgeql->IR compiler need to create statements and fill in
# the subject later, but making it Optional would cause lots of errors,
# so we stick a bogus Empty set in.
subject: Set = EmptySet() # type: ignore
# so we stick a dummy set in.
subject: Set = DUMMY_SET
# Conflict checks that we should manually raise constraint violations
# for.
conflict_checks: typing.Optional[typing.List[OnConflictClause]] = None
Expand Down

0 comments on commit e0d869b

Please sign in to comment.