File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -162,10 +162,10 @@ static SymresStatus symres_union_type(AstUnionType* u_node) {
162
162
u_node -> flags |= Ast_Flag_Comptime ;
163
163
164
164
if (!u_node -> tag_backing_type ) {
165
- int n = (32 - bh_clz (bh_arr_length (u_node -> variants ))) >> 3 ;
166
- if (n <= 1 ) u_node -> tag_backing_type = (AstType * ) & basic_type_u8 ;
167
- else if (n == 2 ) u_node -> tag_backing_type = (AstType * ) & basic_type_u16 ;
168
- else if (n = = 3 ) u_node -> tag_backing_type = (AstType * ) & basic_type_u32 ;
165
+ int n = (31 - bh_clz (bh_arr_length (u_node -> variants ) - 1 )) >> 3 ;
166
+ if (n == 0 ) u_node -> tag_backing_type = (AstType * ) & basic_type_u8 ;
167
+ else if (n == 1 ) u_node -> tag_backing_type = (AstType * ) & basic_type_u16 ;
168
+ else if (n < = 3 ) u_node -> tag_backing_type = (AstType * ) & basic_type_u32 ;
169
169
else {
170
170
onyx_report_error (u_node -> token -> pos , Error_Critical , "Too many union variants. How did you even do this...?" );
171
171
return Symres_Error ;
You can’t perform that action at this time.
0 commit comments