-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
stage1 and stage2: closes #7120 #7122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- The stage2 part is missing?
- This needs a compile-error test
- The commit messages are really bad, have a look here for inspiration
@@ -29544,6 +29544,23 @@ static IrInstGen *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | |||
} | |||
} | |||
} | |||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} else { | |
} else if (!type_is_global_error_set(switch_type)) { |
You can save a whole indentation level.
} else { | ||
if (!type_is_global_error_set(switch_type)) { | ||
bool needs_else = false; | ||
for (uint32_t i = 0; i < switch_type->data.error_set.err_count; i += 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this a more expensive version of const bool needs_else = instruction->range_count != switch_type->data.error_set.err_count
?
By the time you reach this line the compiler already knows all the values are correctly typed and the prong list contains no duplicates.
|
||
AstNode *prev_node = field_prev_uses[err_entry->value]; | ||
if (prev_node == nullptr) { | ||
needs_else = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyway, the indentation is off and you can exit with a break
once this becomes true
.
Thanks. I think I am going to close this pr as #5693 is already trying to handle it and also vexu said that it was intentional #7120 (comment). |
This fixes a case where
was allowed. Funnily, the stdlib and some parts of stage2 included this pattern, so I fixed it there too.
My editor does weird stuff with whitespace, so feel free to ignore that.
See here for conversation on irc.