mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-08 05:35:22 +00:00
Fix scan_expression and compile_dict
This commit is contained in:
parent
5e7b909552
commit
375d592562
2 changed files with 11 additions and 3 deletions
|
@ -1986,12 +1986,18 @@ impl Compiler {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn compile_dict(&mut self, keys: &[ast::Expr], values: &[ast::Expr]) -> CompileResult<()> {
|
||||
fn compile_dict(
|
||||
&mut self,
|
||||
keys: &[Option<ast::Expr>],
|
||||
values: &[ast::Expr],
|
||||
) -> CompileResult<()> {
|
||||
let mut size = 0;
|
||||
|
||||
let (packed_values, unpacked_values) = values.split_at(keys.len());
|
||||
for (key, value) in keys.iter().zip(packed_values) {
|
||||
self.compile_expression(key)?;
|
||||
if let Some(key) = key {
|
||||
self.compile_expression(key)?;
|
||||
}
|
||||
self.compile_expression(value)?;
|
||||
size += 1;
|
||||
}
|
||||
|
|
|
@ -887,7 +887,9 @@ impl SymbolTableBuilder {
|
|||
Dict { keys, values } => {
|
||||
let (packed, unpacked) = values.split_at(keys.len());
|
||||
for (key, value) in keys.iter().zip(packed) {
|
||||
self.scan_expression(key, context)?;
|
||||
if let Some(key) = key {
|
||||
self.scan_expression(key, context)?;
|
||||
}
|
||||
self.scan_expression(value, context)?;
|
||||
}
|
||||
for value in unpacked {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue