[WIP] Use Ruff Parser#5423
Conversation
|
I am glad to see this, awesome. |
|
I was also wondering if this would be possible! Very cool :) |
|
There is a proc macro panic witch I did not understand. Could you try to solve it? @youknowone |
| // ext_modules!( | ||
| // iter, | ||
| // dir = "./Lib/python_builtins", | ||
| // crate_name = "rustpython_compiler_core" | ||
| // ); |
There was a problem hiding this comment.
I am sorry to be late.
The error caused when compiling Lib/python_builtins/__phello__/spam.py
Parsing step is ok, but compiling fails.
| res.map_err(|e| e.into_codegen_error(source_path.to_owned()).into()) | ||
| res.map_err(|e| e.into_codegen_error(source_code.path.to_owned()).into()) | ||
| } | ||
|
|
There was a problem hiding this comment.
I couldn't find the root cause yet, but adding this test will make using debugger or backtrace easy for the problem
| #[test] | |
| fn test_compile_phello() { | |
| let code = r#" | |
| initialized = True | |
| def main(): | |
| print("Hello world!") | |
| if __name__ == '__main__': | |
| main() | |
| "#; | |
| let compiled = compile(&code, Mode::Exec, "<>", CompileOpts::default()); | |
| dbg!(compiled.expect("compile error")); | |
| } |
running with
cargo test --manifest-path compiler/Cargo.toml|
Hi, what is the status on PR? I can work on this if needed. |
|
@etaloof Could you please help? This PR need additonal works to make the upper commented new test passes |
|
Sure, should I make a new PR when I am done? I don't think Github allows me to add my commits here. |
| // If there are type params, we need to push a special symbol table just for them | ||
| if !type_params.is_empty() { | ||
| if !type_params.is_some() { | ||
| self.push_symbol_table(); | ||
| } |
There was a problem hiding this comment.
@qingshi163 @youknowone: This is the source of the bug.
As the comment says, // If there are type params, we need to push a special symbol table just for them, but the change to !type_params.is_some() (as in type_params.is_none()) pushes if there are NO params, causing the panic! in push_symbol_table. On my machine changing to
if type_params.is_some() {
self.push_symbol_table();
}allows test_compile_phello to pass.
# Conflicts: # Cargo.lock # Cargo.toml # compiler/codegen/src/compile.rs # compiler/codegen/src/symboltable.rs # wasm/lib/src/convert.rs
|
oh no... I forget to reset upstream to @etaloof's, now it is pushed here |
|
Superseded by #5494 |
closes #5299