Zilliqa / scilla

Scilla - A Smart Contract Intermediate Level Language
https://scilla-lang.org
GNU General Public License v3.0
240 stars 79 forks source link

DeadCodeDetector: Handle more cases with unused ADT constructors #1121

Closed jubnzv closed 2 years ago

jubnzv commented 2 years ago

Consider an ADT with some unused constructors. If this ADT is not used as an argument of transition, its constructors will be reported as dead. Even if this ADT is a part of another ADT (which is also must not be used in arguments of transitions).

Minimal examples that illustrate the implemented changes:

type A =
| A1 (* A1 is unused, but we don't report it, because A is used in
        constructors of B, which comes from transition `foo`. *)
type B =
| B1 of A

transition foo(b : B)
end
type A =
| A1 (* Report A1, because it is unused and neither A and B are used in
        arguments of transitions. *)
type B =
| B1 of A

procedure bar(b : B)
end

Closes #1118