Skip to content

Another Temporary variable declared too late #15342

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
peblpebl opened this issue Apr 24, 2017 · 3 comments
Closed

Another Temporary variable declared too late #15342

peblpebl opened this issue Apr 24, 2017 · 3 comments
Labels
Duplicate An existing issue was already created

Comments

@peblpebl
Copy link

peblpebl commented Apr 24, 2017

Code

playground

class C {
foo(arg1, arg2) {
[arg1, arg2] = [arg2, arg1];
return arg1;
}
}

Expected behavior:

I would expect any temporary variable declaration to be inserted before use (in this case _a).
I would certainly not expect it after a return statement , giving unreachable code.

Actual behavior:

var C = (function () {
function C() {
}
C.prototype.foo = function (arg1, arg2) {
_a = [arg2, arg1], arg1 = _a[0], arg2 = _a[1];
return arg1;
var _a;
};
return C;
}());

@peblpebl
Copy link
Author

peblpebl commented Apr 24, 2017

playground

@ahejlsberg
Copy link
Member

See #4138 and #7297.

@peblpebl
Copy link
Author

Nearly duplicate of #7297.

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Apr 24, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants