@@ -170,7 +170,8 @@ pub mod implementations {
170170 . context ( "there must be a value at the top of the stack for a `bin_op_assign`" ) ?;
171171
172172 let result = {
173- let no_mut: & Primitive = value;
173+ let no_hp = value. move_out_of_heap_primitive_borrow ( ) ?;
174+ let no_mut: & Primitive = & no_hp;
174175
175176 match op. as_str ( ) {
176177 "+=" => ( & * bundle. primitive ( ) + no_mut) ?,
@@ -187,7 +188,8 @@ pub mod implementations {
187188 } else {
188189 let value = ctx
189190 . pop ( )
190- . context ( "there must be a value at the top of the stack for a `bin_op_assign`" ) ?;
191+ . context ( "there must be a value at the top of the stack for a `bin_op_assign`" ) ?
192+ . move_out_of_heap_primitive ( ) ?;
191193
192194 let Some ( maybe_ptr) = ctx. get_last_op_item_mut ( ) else {
193195 bail ! ( "`bin_op_assign` without a name argument will attempt to modify a pointer that is second to last on the stack, but no primitive was there" ) ;
@@ -1461,7 +1463,8 @@ pub mod implementations {
14611463 */
14621464 #[ allow( clippy:: mutable_key_type) ]
14631465 let raw_map = if let Some ( first) = args. first ( ) {
1464- let capacity = str:: parse :: < usize > ( first) . context ( "could not parse usize for map capacity" ) ?;
1466+ let capacity =
1467+ str:: parse :: < usize > ( first) . context ( "could not parse usize for map capacity" ) ?;
14651468 HashMap :: with_capacity ( capacity)
14661469 } else {
14671470 HashMap :: new ( )
@@ -1486,25 +1489,32 @@ pub mod implementations {
14861489
14871490 let key = ctx. load_local ( key_register) ?;
14881491
1489- map. insert ( key. primitive ( ) . clone ( ) , ctx. pop ( ) . expect ( "no value in the op stack" ) ) ?;
1492+ map. insert (
1493+ key. primitive ( ) . clone ( ) ,
1494+ ctx. pop ( ) . expect ( "no value in the op stack" ) ,
1495+ ) ?;
14901496
14911497 Ok ( ( ) )
14921498 }
14931499
1494-
14951500 #[ inline( always) ]
14961501 pub ( crate ) fn map_op ( ctx : & mut Ctx , args : & [ String ] ) -> Result < ( ) > {
14971502 let map_register = args. first ( ) . context ( "no map register arg" ) ?;
14981503
14991504 let index_key = ctx. pop ( ) . context ( "no index in the stack" ) ?;
15001505
1501- let map = ctx. load_local ( map_register) . with_context ( || format ! ( "no map at register {map_register}" ) ) ?;
1506+ let map = ctx
1507+ . load_local ( map_register)
1508+ . with_context ( || format ! ( "no map at register {map_register}" ) ) ?;
15021509
15031510 let Primitive :: Map ( map) = & * map. primitive ( ) else {
1504- bail ! ( "not a map" )
1511+ bail ! ( "{} is not a map" , map . primitive ( ) )
15051512 } ;
15061513
1507- ctx. push ( Primitive :: HeapPrimitive ( HeapPrimitive :: MapPtr ( map. clone ( ) , Box :: new ( index_key) ) ) ) ;
1514+ ctx. push ( Primitive :: HeapPrimitive ( HeapPrimitive :: MapPtr (
1515+ map. clone ( ) ,
1516+ Box :: new ( index_key) ,
1517+ ) ) ) ;
15081518
15091519 Ok ( ( ) )
15101520 }
0 commit comments