FuelLabs / sway

🌴 Empowering everyone to build reliable and efficient smart contracts.
https://docs.fuel.network/docs/sway/
Apache License 2.0
62.79k stars 5.36k forks source link

No Warning for Overlaps in Pattern Matching #6388

Closed IGI-111 closed 1 week ago

IGI-111 commented 1 month ago

CS-FSSA-022 During pattern-matching a user can define a disjunction of multiple different values as a scrutinee for a particular arm like the following example:

match v {
1 => …
1 | 3 => …
}

Such a case will not yield any warning however. The root cause is the initialisation of witness_report at the beginning of usefulness.rs::is_useful_or(). It is initialised to an empty Witnesses (which still counts as true) instead of NoWitness, as is the case for e.g., is_useful_constructed(). Therefore, is_useful_or() will essentially always return true.

ironcev commented 1 week ago

Related to #5097.