Open
Description
Hello everyone,
I'm currently using rustpython to embed an existing python library into a piece of software and I think I might have found a bug.
The goal is to create a dictionary with String keys and Callable entries somewhat like this:
new_dict = {
**{x: lambda y: y + 2 for x in ["a", "b", "c"]},
"d": lambda x: x +1,
}
If I try to run this code through the rustpython executable, I get the error message:
thread 'main' panicked at /home/valentinbuck/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rustpython-codegen-0.3.0/src/compile.rs:311:9:
assertion failed: table.sub_tables.is_empty()
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
This differs from the error I get when I run this code through a VM I constructed myself:
thread 'main' panicked at /home/valentinbuck/.cargo/git/checkouts/rustpython-f8ef4d934ac33cd8/e6c6f96/compiler/codegen/src/compile.rs:481:57:
The symbol must be present in the symbol table, even when it is undefined in python.
However, when I swap the two lines in the dict, it compiles and runs fine:
new_dict = {
"d": lambda x: x +1,
**{x: lambda y: y + 2 for x in ["a", "b", "c"]},
}
I tried looking through the parser to find the place where this happens but had no luck.
Do you have an idea where I could start or what is going wrong?
Thanks a lot for your project!