After looking at Canonicalize.Sort
, here are my initial thoughts:
- Canonicalize.Sort seems like the right place to make the reference-graph used by Dead-Code elimination
- If we stored the reference-graph information in Canonical.Def, we could use that information in a lot of analyses later on (like variable assignment in TCO).
- There's enough information in the current graph to do dead-code-elimination, but not enough to do unused-variable warnings that would also work for arguments and pattern matches.
I don't think the changes we would need to make would be that significant. Right now, we only look at what free variables a Definition references. If we also look at what bound variables it references (i.e. variables defined inside the reference by Lambdas or pattern matches), then we could issue the proper warnings.
This would, I think, just amount to storing a record with referenced free and bound variables,