Skip to content

[MERGED] warning 24X: enum item "%s" not handled in switch #549

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

Closed

Conversation

Daniel-Cortez
Copy link
Contributor

@Daniel-Cortez Daniel-Cortez commented Jun 30, 2020

What this PR does / why we need it:

This PR adds a new diagnostic that warns the user if an item of a named enumeration is not covered by any of the switch cases, as suggested in #528.
Example:

enum EFamily
{
	FAM_GROVE,
	FAM_BALLAS,
	FAM_VAGOS,
	FAM_AZTECAS
};

stock GetFamilyColor(EFamily:family)
{
	switch (family)
	{
		// NOTE: The user forgot to add a case for "FAM_AZTECAS"
		case FAM_GROVE:   return COLOR_GREEN;
		case FAM_BALLAS:  return COLOR_PURPLE;
		case FAM_VAGOS:   return COLOR_YELLOW;
	} // warning 24X: enum item "FAM_AZTECAS" not handled in switch
	return COLOR_GREY;
}

Which issue(s) this PR fixes:

Fixes #

What kind of pull this is:

  • A Bug Fix
  • A New Feature
  • Some repository meta (documentation, etc)
  • Other

Additional Documentation:

@Daniel-Cortez Daniel-Cortez requested a review from a team as a code owner June 30, 2020 16:27
@Y-Less Y-Less closed this Sep 19, 2020
@Y-Less Y-Less changed the title warning 24X: enum item "%s" not handled in switch [MERGED] warning 24X: enum item "%s" not handled in switch Sep 20, 2020
@Daniel-Cortez Daniel-Cortez deleted the wswitch-enum-coverage branch October 19, 2020 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants