Skip to content

Commit 24ecf60

Browse files
youknowoneclaude
andcommitted
Address additional CodeRabbit review comments
- Fix top-level scope check: only block if super is bound (not just used) - Add doc comments for LOAD_SUPER_* pseudo opcodes Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 2508021 commit 24ecf60

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

‎crates/codegen/src/compile.rs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -720,9 +720,11 @@ impl Compiler {
720720
{
721721
return None;
722722
}
723-
// Also check top-level scope to detect module-level shadowing
723+
// Also check top-level scope to detect module-level shadowing.
724+
// Only block if super is actually *bound* at module level (not just used).
724725
if let Some(top_table) = self.symbol_table_stack.first()
725-
&& top_table.lookup("super").is_some()
726+
&& let Some(sym) = top_table.lookup("super")
727+
&& sym.scope != SymbolScope::GlobalImplicit
726728
{
727729
return None;
728730
}

‎crates/compiler-core/src/bytecode/instruction.rs‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,16 +245,21 @@ pub enum Instruction {
245245
arg: Arg<u32>,
246246
} = 149,
247247
// ===== LOAD_SUPER_* Pseudo Opcodes (136-138) =====
248-
// These are converted to LoadSuperAttr during bytecode finalization
248+
// These are converted to LoadSuperAttr during bytecode finalization.
249+
// "Zero" variants are for 0-arg super() calls (has_class=false).
250+
// Non-"Zero" variants are for 2-arg super(cls, self) calls (has_class=true).
251+
/// 2-arg super(cls, self).method() - has_class=true, load_method=true
249252
LoadSuperMethod {
250253
idx: Arg<NameIdx>,
251-
} = 136, // CPython uses pseudo-op 260
254+
} = 136,
255+
/// 0-arg super().attr - has_class=false, load_method=false
252256
LoadZeroSuperAttr {
253257
idx: Arg<NameIdx>,
254-
} = 137, // CPython uses pseudo-op 261
258+
} = 137,
259+
/// 0-arg super().method() - has_class=false, load_method=true
255260
LoadZeroSuperMethod {
256261
idx: Arg<NameIdx>,
257-
} = 138, // CPython uses pseudo-op 262
262+
} = 138,
258263
// ==================== RustPython-only instructions (119-135) ====================
259264
// Ideally, we want to be fully aligned with CPython opcodes, but we still have some leftovers.
260265
// So we assign random IDs to these opcodes.

0 commit comments

Comments
 (0)