Skip to content

Commit 2257d76

Browse files
Fix variable shadowing
1 parent a71f6c1 commit 2257d76

File tree

3 files changed

+3
-6
lines changed

3 files changed

+3
-6
lines changed

docs/changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ _This project uses semantic versioning_
77
- Upgrade egglog which includes new backend.
88
- Fixes implementation of the Python Object sort to work with objects with dupliating hashes but the same value.
99
Also changes the representation to be an index into a list instead of the ID, making egglog programs more deterministic.
10-
- Prefix constant declerations to not shadow local variables
10+
- Prefix constant declerations and unbound variables to not shadow let variables
1111
- BREAKING: Remove `simplify` since it was removed upstream. You can manually replace it with an insert, run, then extract.
1212

1313
## 10.0.2 (2025-06-22)

python/egglog/egraph_state.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,8 @@ def _expr_to_egg(self, expr_decl: ExprDecl) -> bindings._Expr: # noqa: PLR0912,
406406
case LetRefDecl(name):
407407
res = bindings.Var(span(), f"{name}")
408408
case UnboundVarDecl(name):
409-
res = bindings.Var(span(), name)
409+
# Prefix vars with an _ to avoid name conflicts
410+
res = bindings.Var(span(), f"_{name}")
410411
case LitDecl(value):
411412
l: bindings._Literal
412413
match value:

python/tests/test_unstable_fn.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,6 @@ def apply_f(f: Callable[[A], A], x: A) -> A:
315315
egraph = EGraph(save_egglog_string=True)
316316
x = egraph.let("x", apply_f(lambda x: A(), A()))
317317
y = egraph.let("y", apply_f(lambda x: alt_a, A()))
318-
print(egraph.run(10))
319-
print(egraph.extract(x))
320-
print(egraph.as_egglog_string)
321-
egraph.display(n_inline_leaves=0)
322318
egraph.check(eq(x).to(A()))
323319
egraph.check(eq(y).to(alt_a))
324320

0 commit comments

Comments
 (0)