@@ -249,9 +249,8 @@ pub fn deserialize_code<R: Read, Bag: ConstantBag>(
249249 let instructions = CodeUnits :: try_from ( code_bytes. as_slice ( ) ) ?;
250250 let locations = linetable_to_locations ( & linetable, first_line_raw, instructions. len ( ) ) ;
251251
252- // Build localspluskinds from split vars (matching CodeObject's merged layout)
253- let localspluskinds =
254- build_localspluskinds_from_split ( & lp. varnames , & lp. cellvars , & lp. freevars ) ;
252+ // Use original localspluskinds from marshal data (preserves CO_FAST_HIDDEN etc.)
253+ let localspluskinds = localspluskinds. into_boxed_slice ( ) ;
255254
256255 Ok ( CodeObject {
257256 instructions,
@@ -1035,41 +1034,6 @@ pub struct LocalsPlusResult<S> {
10351034 pub deref_map : Vec < u32 > ,
10361035}
10371036
1038- /// Build localspluskinds from split varnames/cellvars/freevars.
1039- /// This produces the merged layout matching CodeObject's localspluskinds field.
1040- fn build_localspluskinds_from_split < S : AsRef < str > > (
1041- varnames : & [ S ] ,
1042- cellvars : & [ S ] ,
1043- freevars : & [ S ] ,
1044- ) -> Box < [ u8 ] > {
1045- let nlocals = varnames. len ( ) ;
1046- let ncells = cellvars. len ( ) ;
1047- let nfrees = freevars. len ( ) ;
1048- let numdropped = cellvars
1049- . iter ( )
1050- . filter ( |cv| varnames. iter ( ) . any ( |v| v. as_ref ( ) == cv. as_ref ( ) ) )
1051- . count ( ) ;
1052- let nlocalsplus = nlocals + ncells - numdropped + nfrees;
1053- let mut kinds = alloc:: vec![ 0u8 ; nlocalsplus] ;
1054- for kind in kinds. iter_mut ( ) . take ( nlocals) {
1055- * kind = CO_FAST_LOCAL ;
1056- }
1057- let mut cell_numdropped = 0usize ;
1058- for ( i, cv) in cellvars. iter ( ) . enumerate ( ) {
1059- if let Some ( local_idx) = varnames. iter ( ) . position ( |v| v. as_ref ( ) == cv. as_ref ( ) ) {
1060- kinds[ local_idx] |= CO_FAST_CELL ;
1061- cell_numdropped += 1 ;
1062- } else {
1063- kinds[ nlocals + i - cell_numdropped] = CO_FAST_CELL ;
1064- }
1065- }
1066- let free_start = nlocals + ncells - numdropped;
1067- for i in 0 ..nfrees {
1068- kinds[ free_start + i] = CO_FAST_FREE ;
1069- }
1070- kinds. into_boxed_slice ( )
1071- }
1072-
10731037pub fn split_localplus < S : Clone > (
10741038 names : & [ S ] ,
10751039 kinds : & [ u8 ] ,
0 commit comments