-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[CS2] Nodes, Scope: Assignment in dynamic method names #4425
Comments
There is a separate error case related to class scope, which is attempting to use anything assigned in an executable class body within a class dynamic method name, e.g.: class A
getName = -> 'm'
"#{getName()}": -> which currently compiles to var A;
A = (function() {
var getName;
class A {
// note that getName hasn't been assigned yet
[`${getName()}`]() {}
};
getName = function() {
return 'm';
};
return A;
})(); I discussed this at some length in the classes PRs, but couldn't settle on an appropriate solution. Options include:
I think 4. sounds best. I reckon this combination of things should be fairly rare, and option 4. allows the pattern to be used if truly desired, whilst making the trade-off clearer than option 2. Option 3. might be a good option, but I'm not sure what we'd need to check for. That the expression for a dynamic name contains no variables from the executable body scope? That should be possible with |
Fixed by #4426. |
compiles to
The text was updated successfully, but these errors were encountered: