Skip to content

Commit 860a3db

Browse files
committed
Skip list→tuple optimization for async for; propagate future_annotations to nested scopes
1 parent c2473c3 commit 860a3db

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

crates/codegen/src/compile.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5460,7 +5460,8 @@ impl Compiler {
54605460
// Optimize: `for x in [a, b, c]` → use tuple instead of list
54615461
// (list creation is wasteful for iteration)
54625462
// Skip optimization if any element is starred (e.g., `[a, *b, c]`)
5463-
if let ast::Expr::List(ast::ExprList { elts, .. }) = iter
5463+
if !is_async
5464+
&& let ast::Expr::List(ast::ExprList { elts, .. }) = iter
54645465
&& !elts.iter().any(|e| matches!(e, ast::Expr::Starred(_)))
54655466
{
54665467
for elt in elts {

crates/codegen/src/symboltable.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,7 @@ impl SymbolTableBuilder {
10351035
.and_then(|t| t.mangled_names.clone())
10361036
.filter(|_| typ != CompilerScope::Class);
10371037
let mut table = SymbolTable::new(name.to_owned(), typ, line_number, is_nested);
1038+
table.future_annotations = self.future_annotations;
10381039
table.mangled_names = inherited_mangled_names;
10391040
self.tables.push(table);
10401041
// Save parent's varnames and start fresh for the new scope

0 commit comments

Comments
 (0)