@@ -401,7 +401,7 @@ impl Compiler {
401401
402402/// Compile a slice expression
403403// = compiler_slice
404- fn compile_slice ( & mut self , s : & ExprSlice ) ->CompileResult < u32 > {
404+ fn compile_slice ( & mut self , s : & ExprSlice ) ->CompileResult < BuildSliceArgCount > {
405405// Compile lower
406406if let Some ( lower) =& s. lower {
407407self . compile_expression ( lower) ?;
@@ -416,13 +416,14 @@ impl Compiler {
416416self . emit_load_const ( ConstantData :: None ) ;
417417}
418418
419- // Compile step if present
420- if let Some ( step) =& s. step {
421- self . compile_expression ( step) ?;
422- Ok ( 3 ) // Three values on stack
423- } else {
424- Ok ( 2 ) // Two values on stack
425- }
419+ Ok ( match & s. step {
420+ Some ( step) =>{
421+ // Compile step if present
422+ self . compile_expression ( step) ?;
423+ BuildSliceArgCount :: Three
424+ }
425+ None =>BuildSliceArgCount :: Two ,
426+ } )
426427}
427428
428429/// Compile a subscript expression
@@ -449,29 +450,19 @@ impl Compiler {
449450
450451// Handle two-element slice (for Load/Store, not Del)
451452if Self :: is_two_element_slice ( slice) && !matches ! ( ctx, ExprContext :: Del ) {
452- let n =match slice{
453+ let argc =match slice{
453454Expr :: Slice ( s) =>self . compile_slice ( s) ?,
454455 _ =>unreachable ! ( "is_two_element_slice should only return true for Expr::Slice" ) ,
455456} ;
456457match ctx{
457458ExprContext :: Load =>{
458459// CPython uses BINARY_SLICE
459- emit ! (
460- self ,
461- Instruction :: BuildSlice {
462- argc: BuildSliceArgCount :: from_op_arg( n) . unwrap( )
463- }
464- ) ;
460+ emit ! ( self , Instruction :: BuildSlice { argc} ) ;
465461emit ! ( self , Instruction :: Subscript ) ;
466462}
467463ExprContext :: Store =>{
468464// CPython uses STORE_SLICE
469- emit ! (
470- self ,
471- Instruction :: BuildSlice {
472- argc: BuildSliceArgCount :: from_op_arg( n) . unwrap( )
473- }
474- ) ;
465+ emit ! ( self , Instruction :: BuildSlice { argc} ) ;
475466emit ! ( self , Instruction :: StoreSubscript ) ;
476467}
477468 _ =>unreachable ! ( ) ,