Skip to content

Exclude unused function declarations... - #90

Merged
Rich-Harris merged 5 commits into
masterfrom
gh-37-b
Aug 21, 2015
Merged

Exclude unused function declarations...#90
Rich-Harris merged 5 commits into
masterfrom
gh-37-b

Conversation

@Rich-Harris

Copy link
Copy Markdown
Contributor

...that happen to mutate things that are used. This is a more conservative version of #49, which poses slightly harder challenges. No sense in letting perfect be the enemy of good, etc etc.

Essentially, if ensures that unused doesn't get included in situations like this:

var obj = {};

function unused () { obj.mutated = true; }

// or alternatively
var unused = function () { obj.mutated = true; }

@eventualbuddha

Copy link
Copy Markdown
Contributor

I don't pretend to understand exactly what readDepth and writeDepth do, but this seems good based on the tests passing.

@Rich-Harris

Copy link
Copy Markdown
Contributor Author

Yeah, I'm not great at naming things 😬

readDepth allows us to distinguish between strong and weak dependencies (i.e. class A extends B indicates A has a strong dependency on B, whereas function foo () { return bar } indicates foo has a weak dependency on bar, because the code doesn't run immediately), and writeDepth determines whether foo.bar = baz should be deemed to mutate foo based on whether it's at the top level or inside a function.

Very much open to any suggestions on how to clarify this stuff in the code!

Rich-Harris added a commit that referenced this pull request Aug 21, 2015
Exclude unused function declarations...
@Rich-Harris
Rich-Harris merged commit 4e11b0c into master Aug 21, 2015
@Rich-Harris
Rich-Harris deleted the gh-37-b branch August 21, 2015 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants