Skip to content

Commit c77c00b

Browse files
committed
minor fix
1 parent 1d7d7b0 commit c77c00b

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

compiler/codegen/src/compile.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3563,8 +3563,9 @@ impl Compiler {
35633563
}
35643564

35653565
// Validate and compile keys
3566-
use std::collections::HashSet;
3567-
let mut seen = HashSet::new();
3566+
// NOTE: RustPython difference - using HashSet<String> for duplicate checking
3567+
// CPython uses PySet with actual Python objects
3568+
let mut seen = std::collections::HashSet::new();
35683569

35693570
for key in keys.iter() {
35703571
// Validate key

vm/src/frame.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -680,8 +680,8 @@ impl ExecutingFrame<'_> {
680680
bytecode::Instruction::StoreSubscript => self.execute_store_subscript(vm),
681681
bytecode::Instruction::DeleteSubscript => self.execute_delete_subscript(vm),
682682
bytecode::Instruction::CopyItem { index } => {
683-
// CopyItem { index: 1 } copies TOS (like Python's COPY 1)
684-
// CopyItem { index: 2 } copies second from top (like Python's COPY 2)
683+
// CopyItem { index: 1 } copies TOS
684+
// CopyItem { index: 2 } copies second from top
685685
// This is 1-indexed to match CPython
686686
let idx = index.get(arg) as usize;
687687
let value = self
@@ -705,7 +705,7 @@ impl ExecutingFrame<'_> {
705705
let index_val = index.get(arg) as usize;
706706
// CPython: SWAP(n) swaps TOS with PEEK(n) where PEEK(n) = stack_pointer[-n]
707707
// This means swap TOS with the element at index (len - n)
708-
let j = len.saturating_sub(index_val);
708+
let j = len - index_val;
709709
self.state.stack.swap(i, j);
710710
Ok(None)
711711
}

0 commit comments

Comments
 (0)