@@ -78,12 +78,6 @@ static jl_array_t *_new_array_(jl_value_t *atype, uint32_t ndims, size_t *dims,
78
78
// extra byte for all julia allocated byte arrays
79
79
tot ++ ;
80
80
}
81
- jl_value_t * el_type = (jl_value_t * )jl_tparam0 (jl_typeof (atype ));
82
- if (jl_is_uniontype (el_type )) {
83
- printf ("here 3" );
84
- // allocate an extra sel byte for each element
85
- tot += nel ;
86
- }
87
81
}
88
82
else {
89
83
wideint_t prod = (wideint_t )sizeof (void * ) * (wideint_t )nel ;
@@ -155,7 +149,7 @@ static inline jl_array_t *_new_array(jl_value_t *atype, uint32_t ndims, size_t *
155
149
if (jl_is_uniontype (el_type )) {
156
150
size_t fsz = 0 , al = 0 ;
157
151
unsigned countbits = jl_union_isbits (el_type , & fsz , & al );
158
- elsz = fsz ;
152
+ elsz = fsz + 1 ;
159
153
}
160
154
else {
161
155
elsz = jl_datatype_size (el_type );
@@ -504,8 +498,7 @@ JL_DLLEXPORT jl_value_t *jl_arrayref(jl_array_t *a, size_t i)
504
498
if (!a -> flags .ptrarray ) {
505
499
jl_value_t * el_type = (jl_value_t * )jl_tparam0 (jl_typeof (a ));
506
500
if (jl_is_uniontype (el_type )) {
507
- printf ("here 1" );
508
- uint8_t sel = ((uint8_t * )a -> data )[jl_array_len (a ) * a -> elsize + i ];
501
+ uint8_t sel = ((uint8_t * )a -> data )[jl_array_len (a ) * (a -> elsize - 1 ) + i ];
509
502
el_type = jl_nth_union_component (el_type , sel );
510
503
if (jl_is_datatype_singleton ((jl_datatype_t * )el_type ))
511
504
return ((jl_datatype_t * )el_type )-> instance ;
@@ -570,8 +563,7 @@ JL_DLLEXPORT void jl_arrayset(jl_array_t *a, jl_value_t *rhs, size_t i)
570
563
}
571
564
if (!a -> flags .ptrarray ) {
572
565
if (jl_is_uniontype (el_type )) {
573
- printf ("here 2" );
574
- uint8_t * psel = & ((uint8_t * )a -> data )[jl_array_len (a ) * a -> elsize + i ];
566
+ uint8_t * psel = & ((uint8_t * )a -> data )[jl_array_len (a ) * (a -> elsize - 1 ) + i ];
575
567
unsigned nth = 0 ;
576
568
if (!jl_find_union_component (el_type , jl_typeof (rhs ), & nth ))
577
569
assert (0 && "invalid field assignment to isbits union" );
0 commit comments