Functional Logic & Control Flow

Incorrect enum/constant comparison

Last updated: 4 Mar 2026

Definition

Branches compare the wrong symbol/value or mix representations (e.g., string vs. numeric).

How to fix Incorrect enum/constant comparison?

Use strongly typed enums; avoid magic numbers; centralize mappings; add exhaustive switch checks and negative tests

Symptoms

Observable signs that may indicate Incorrect enum/constant comparison:

  • Switch/case fallbacks triggered unexpectedly.
  • Branching behaves differently across platforms/types.
  • Magic numbers used instead of enum symbols.

Example Errors:

  • Type mismatch in comparison
  • Case not handled for value
  • Assignment used where comparison intended