From e0d869b58aab6549bfdbaf5acdb5d65422e9beee Mon Sep 17 00:00:00 2001 From: "Michael J. Sullivan" Date: Thu, 21 Mar 2024 11:41:59 -0700 Subject: [PATCH] Drop explicit use of EmptySet as a dummy set (#7093) Instead declare a DUMMY_SET in irast. This generally seems cleaner and helps prepare for eliminating EmptySet as part of the IR refactors. --- edb/edgeql/compiler/casts.py | 2 +- edb/edgeql/compiler/polyres.py | 2 +- edb/ir/ast.py | 17 ++++++++++------- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/edb/edgeql/compiler/casts.py b/edb/edgeql/compiler/casts.py index d401afc3a43..70ce470cecd 100644 --- a/edb/edgeql/compiler/casts.py +++ b/edb/edgeql/compiler/casts.py @@ -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), diff --git a/edb/edgeql/compiler/polyres.py b/edb/edgeql/compiler/polyres.py index b07e06e6b3a..bc9e330ff63 100644 --- a/edb/edgeql/compiler/polyres.py +++ b/edb/edgeql/compiler/polyres.py @@ -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( diff --git a/edb/ir/ast.py b/edb/ir/ast.py index d1811aba2eb..128622c2567 100644 --- a/edb/ir/ast.py +++ b/edb/ir/ast.py @@ -613,6 +613,9 @@ def __repr__(self) -> str: Set = SetE +DUMMY_SET = Set() # type: ignore[call-arg] + + class Command(Base): __abstract_node__ = True @@ -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 @@ -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 @@ -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