Skip to content

Commit 7a03b28

Browse files
committed
backup2
1 parent 3c33d35 commit 7a03b28

File tree

1 file changed

+2
-26
lines changed

1 file changed

+2
-26
lines changed

compiler/codegen/src/compile.rs

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,6 @@ impl Compiler<'_> {
430430
slice: &Expr,
431431
ctx: ExprContext,
432432
) -> CompileResult<()> {
433-
// In CPython:
434433
// 1. Check subscripter and index for Load context
435434
// 2. VISIT value
436435
// 3. Handle two-element slice specially
@@ -463,7 +462,7 @@ impl Compiler<'_> {
463462
}
464463
} else {
465464
// VISIT(c, expr, e->v.Subscript.slice)
466-
self.compile_subscript_slice(slice)?;
465+
self.compile_expression(slice)?;
467466

468467
// Emit appropriate instruction based on context
469468
match ctx {
@@ -481,29 +480,6 @@ impl Compiler<'_> {
481480
Ok(())
482481
}
483482

484-
/// Compile a subscript slice, handling starred expressions in tuples
485-
// = compiler_subscript() - specifically the VISIT(c, expr, slice) part
486-
fn compile_subscript_slice(&mut self, slice: &Expr) -> CompileResult<()> {
487-
// In CPython, compiler_subscript just does VISIT(c, expr, e->v.Subscript.slice)
488-
// which calls compiler_visit_expr, which in turn calls compiler_tuple for Tuple_kind
489-
// In Load context, compiler_tuple uses starunpack_helper
490-
491-
match slice {
492-
// Special handling for tuple in subscript context
493-
// This matches CPython's compiler_tuple behavior for Load context
494-
Expr::Tuple(ExprTuple { elts, ctx, .. }) if matches!(ctx, ExprContext::Load) => {
495-
// Use starunpack_helper to handle potential starred expressions
496-
// This is equivalent to CPython's compiler_tuple calling starunpack_helper
497-
self.starunpack_helper(elts, 0, CollectionType::Tuple)?;
498-
}
499-
// For all other cases (including Store/Del context tuples), compile normally
500-
_ => {
501-
self.compile_expression(slice)?;
502-
}
503-
}
504-
Ok(())
505-
}
506-
507483
/// Helper function for compiling tuples/lists/sets with starred expressions
508484
///
509485
/// Parameters:
@@ -4220,7 +4196,7 @@ impl Compiler<'_> {
42204196
// For augmented assignment, we need to load the value first
42214197
// But we can't use compile_subscript directly because we need DUP_TOP2
42224198
self.compile_expression(value)?;
4223-
self.compile_subscript_slice(slice)?;
4199+
self.compile_expression(slice)?;
42244200
emit!(self, Instruction::Duplicate2);
42254201
emit!(self, Instruction::Subscript);
42264202
AugAssignKind::Subscript

0 commit comments

Comments
 (0)