github / semantic

Parsing, analyzing, and comparing source code across many languages
8.94k stars 453 forks source link

Dead code analysis #714

Closed robrix closed 5 months ago

robrix commented 5 months ago

Run it like so:

deadCodeFlowInsensitive Analysis.Syntax.eval Analysis.Syntax.subterms [Analysis.File.File (Analysis.Reference.Reference "" (Source.Span.Span (Source.Span.Pos 0 0) (Source.Span.Pos 1 1))) (Analysis.Syntax.String (Data.String.fromString ""))]

to get a result like so:

( fromList []
, …
, …
)

which shows us (by its exclusion) that the entire input program is live.

robrix commented 5 months ago

NB: we currently evaluate function bodies at their definition sites, which means that all code ends up appearing live. I'm switching focus to another part of the system for the moment, so I'm postponing that issue to another PR.