Fix #2489 once more -- preserve bound methods arity #3260
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Since compiler hacking is way more fun than CLI fixing, here's my version of "Fix #2489 again"
_bindMethods
function wherein all binding takes place.This preserves the readability of the compiled constructor and avoids any potential memory leaks (related: Fat arrow leaks generated
_this
reference to other closures #3143).This comes with a hefty dose of ugly. Though I doubt the compilation could get much nicer. Compare #3258 which fixes this issue in a different way (prettier classes but more helpers).
Based upon prior art by @epidemian and @michaelficarra. Feel free to bash...
Side effect
This PR unintentionally "fixes" #1819 (the same way redux does). This breaks other fun stuff:
I can't really assess the severity of this change since I can't imagine why anybody would ever do anything like that (or #1819 for that matter).
Example compilation