Skip to content
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

"Block-scoped variable used before its declaration" not detected in some cases #7477

Closed
T18970237136 opened this issue Mar 11, 2016 · 0 comments · Fixed by #8425
Closed

"Block-scoped variable used before its declaration" not detected in some cases #7477

T18970237136 opened this issue Mar 11, 2016 · 0 comments · Fixed by #8425
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@T18970237136
Copy link
Contributor

Hi, this is probably only a minor/cosmetic issue, but while trying the code in https://bugzilla.mozilla.org/show_bug.cgi?id=1069480, I found that the Typescript Compiler does not detect that a variable is used before its initialization in a for-of loop with object destructuring using a computed property name.

TypeScript Version:
master (a75a02c)

Code (Playground)

"use strict";

// 1:
for (let {[a]: a} of [{ }]) continue;

// 2:
for (let {[a]: a} = { }; false; ) continue;

// 3:
let {[b]: b} = { };

Expected behavior:
For 1), 2) and 3) the error "Block-scoped variable used before its declaration" should be reported.

Actual behavior:
No error reported for 1), correct errors reported for 2) and 3).

Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants