egraphs-good/snake-egg

Crash when right-hand-side is single variable?

Closed this issue · 4 comments

Hello, thanks for adding this API!

I'm trying to run the tests on my machine but they seem to fail when I include tests that have a single variable on the right-hand-side. For example, the rewrite rule

Rewrite(Add(a, 0), a, name="add-0"),
causes the following error when I run make test:

thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "Rewrite add-0 refers to unbound var ?a"', src/core.rs:88:63
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Traceback (most recent call last):
  File "/Users/fmora/Documents/software/snake-egg/snake_egg/tests/test_simple.py", line 27, in <module>
    Rewrite(Add(a, 0), a, name="add-0"),
pyo3_runtime.PanicException: called `Result::unwrap()` on an `Err` value: "Rewrite add-0 refers to unbound var ?a"
make: *** [test] Error 1

When I comment out all the rewrite rules in the test set that have a single variable on the rhs, this error goes away. Have you seen this before? Do you know what is going on?

Thank you!!

Thanks for the issue! I'm not really paged in on maintaining this project at the moment. Perhaps @saulshanabrook or @IanBriggs might be able to help?

I was seeing that locally as well! I am not sure why it was coming up... I hadn't had time to look into it yet.

I might have an idea as to what is happening. I'll take a look at it.

I took a look and I think it is because there is a misconception about how 'match_args' should work in the code - the code seems to assume that match_args should produce the values, but this is wrong. It should just be a list of strings you can access data with (https://peps.python.org/pep-0622). I will submit a pull shortly.

We should also probably pin python3.10+ for this.