Created
October 6, 2012 10:15
-
-
Save ShinNoNoir/3844548 to your computer and use it in GitHub Desktop.
TypeScript bug report, http://typescript.codeplex.com/workitem/131
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Bug: | |
TypeScript compiler should generate a *fresh* variable name for a lexically captured this pointer. | |
For example, in the lambda assigned to window.onmousemove shown below, the captured outer this-pointer | |
should not be named "_this" since it would clash with an existing local variable, but instead should | |
be given a name that is not in scope, e.g. "_this2". | |
Tested in: | |
http://www.typescriptlang.org/Playground/ | |
*/ | |
class Tracker { | |
count = 0; | |
start() { | |
var _this = 0; | |
window.onmousemove = e => { | |
this.count++; | |
console.log(this.count * _this); | |
} | |
} | |
} | |
var t = new Tracker(); | |
t.start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment