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

Named expression-style classes should assign that name to their scope #867

Closed
alangpierce opened this Issue Feb 25, 2017 · 0 comments

Comments

Projects
None yet
1 participant
@alangpierce
Member

alangpierce commented Feb 25, 2017

decaffeinate is producing the wrong JavaScript based on my CoffeeScript input:

A = class B
console.log(B)

(repl)

I get this output:

const A = class B {};
console.log(B);

Here's what I expect it to be instead:

let B;
const A = B = class B {};
console.log(B);

This is causing the atom tests to fail after decaffeinate.

@alangpierce alangpierce self-assigned this Feb 25, 2017

alangpierce added a commit to alangpierce/decaffeinate that referenced this issue Feb 26, 2017

fix: always generate an assignment for expression-style classes
Fixes decaffeinate#867

Unlike in JavaScript, CoffeeScript named classes assign to their outer scope, so
we need an explicit assignment unless we know the class will be a JS class
declaration statement.

alangpierce added a commit that referenced this issue Feb 26, 2017

fix: always generate an assignment for expression-style classes (#868)
Fixes #867

Unlike in JavaScript, CoffeeScript named classes assign to their outer scope, so
we need an explicit assignment unless we know the class will be a JS class
declaration statement.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment