mirror of
https://github.com/neovim/neovim.git
synced 2025-09-16 16:28:17 +00:00
refactor: allow not having a default
case for enum
Problem: The style guide states that all switch statements that are not conditional on an enum must have a `default` case, but does not give any explicit guideline for switch statements that are conditional on enums. As a result, a `default` case is added in many enum switch statements, even when the switch statement is exhaustive. This is not ideal because it removes the ability to have compiler errors to easily detect unchanged switch statements when a new possible value for an enum is added. Solution: Add explicit guidelines for switch statements that are conditional on an enum, clarifying that a `default` case is not necessary if the switch statement is exhaustive. Also refactor pre-existing code with unnecessary `default` cases.
This commit is contained in:

committed by
Lewis Russell

parent
a2f17e97ec
commit
9ff6f73f83
@@ -6088,9 +6088,6 @@ bool callback_call(Callback *const callback, const int argcount_in, typval_T *co
|
||||
case kCallbackNone:
|
||||
return false;
|
||||
break;
|
||||
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
|
||||
funcexe_T funcexe = FUNCEXE_INIT;
|
||||
@@ -6120,7 +6117,7 @@ bool set_ref_in_callback(Callback *callback, int copyID, ht_stack_T **ht_stack,
|
||||
return set_ref_in_item(&tv, copyID, ht_stack, list_stack);
|
||||
break;
|
||||
|
||||
default:
|
||||
case kCallbackLua:
|
||||
abort();
|
||||
}
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user