-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Warn about dead code within match and if/else #23404
Copy link
Copy link
Closed
Labels
Feature/Enhancement RequestThis issue is made to request a feature or an enhancement to an existing one.This issue is made to request a feature or an enhancement to an existing one.Unit: CompilerBugs/feature requests, that are related to the V compiler in general.Bugs/feature requests, that are related to the V compiler in general.
Description
Metadata
Metadata
Assignees
Labels
Feature/Enhancement RequestThis issue is made to request a feature or an enhancement to an existing one.This issue is made to request a feature or an enhancement to an existing one.Unit: CompilerBugs/feature requests, that are related to the V compiler in general.Bugs/feature requests, that are related to the V compiler in general.
Type
Fields
Give feedbackNo fields configured for Feature.
Describe the feature
A programmer mistake can produce dead code if uses within
if/elsebranches comparisons likea == aand withinmatchlikematch a { a { ... } else { ... } }.The compiler could look for these types of comparisons and issue warnings about the possibility of dead code.
Use Case
Dead code with
ifandelse:Dead code within
match:matchis more robust thanif/elsesince already prevents repeated constants and exhaust the search with mandatoryelse. But with variables or post-calculated constants also can produce dead code. Some examples are in issue #23403Proposed Solution
No response
Other Information
No response
Acknowledgements
Version used
V 0.4.9 9fc8352
Environment details (OS name and version, etc.)
Playground
Huly®: V_0.6-21835
Note
You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.