Overview
- Bug Type:
- Incorrect enum/constant comparison
- Category:
- Functional Logic & Control Flow
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
