Skip to content

Commit

Permalink
fix env_rebind
Browse files Browse the repository at this point in the history
  • Loading branch information
dakk committed Oct 23, 2023
1 parent bf6e7d9 commit 3e865ed
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions qlasskit/ast2logic/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ def __init__(self) -> None:

for t in BUILTIN_TYPES:
self.bind_type((t.__name__, t)) # type: ignore


def __repr__(self):
return str((self.bindings, self.types))

def bind_type(self, bb: TypeBinding):
if self.know_type(bb[0]):
Expand All @@ -50,6 +54,9 @@ def bind(self, bb: Binding, rebind=False):
if not rebind and bb.name in self:
raise Exception("duplicate bind")

if rebind:
self.bindings.remove(self[bb.name])

self.bindings.append(bb)

def __contains__(self, key):
Expand Down

0 comments on commit 3e865ed

Please sign in to comment.