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

Class variable should be under TDZ during ClassFieldDefinitionEvaluation #6732

Closed
gsathya opened this Issue Nov 2, 2017 · 3 comments

Comments

Projects
None yet
2 participants
@gsathya
Member

gsathya commented Nov 2, 2017

Choose one: is this a bug report or feature request?

bug report

Input Code

class C {
  static [C] = new C;
}

Babel/Babylon Configuration (.babelrc, package.json, cli command)

stage2,stage3

Expected Behavior

ReferenceError

Current Behavior

no error

Your Environment

REPL

@maurobringolf

This comment has been minimized.

Show comment
Hide comment
@maurobringolf

maurobringolf Nov 9, 2017

Contributor

Should this also throw without the computed property name?

class C {
  static x = new C;
}
Contributor

maurobringolf commented Nov 9, 2017

Should this also throw without the computed property name?

class C {
  static x = new C;
}
@gsathya

This comment has been minimized.

Show comment
Hide comment
@gsathya

gsathya Nov 9, 2017

Member

No, that's valid. Only ClassFieldDefinitionEvaluation observes the TDZ, not InitializeStaticFields.

Sorry about the confusing example, a better example is

class C {
  static [C];
}
Member

gsathya commented Nov 9, 2017

No, that's valid. Only ClassFieldDefinitionEvaluation observes the TDZ, not InitializeStaticFields.

Sorry about the confusing example, a better example is

class C {
  static [C];
}
@maurobringolf

This comment has been minimized.

Show comment
Hide comment
@maurobringolf

maurobringolf Nov 9, 2017

Contributor

I would like to try this. I tried adding a subtraversal checking all references to the class name inside the property key computation and inserting runtime errors there. It seems to work but I wonder what the preferred approach would be though. The extra traversal seems unnecessary to me, could it possibly also be done via some scoping mechanism?

Contributor

maurobringolf commented Nov 9, 2017

I would like to try this. I tried adding a subtraversal checking all references to the class name inside the property key computation and inserting runtime errors there. It seems to work but I wonder what the preferred approach would be though. The extra traversal seems unnecessary to me, could it possibly also be done via some scoping mechanism?

@lock lock bot added the outdated label May 3, 2018

@lock lock bot locked as resolved and limited conversation to collaborators May 3, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.