babel / babylon

PSA: moved into babel/babel as @babel/parser -->

Home Page:https://github.com/babel/babel/tree/master/packages/babel-parser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ES2016 bind syntax does not work with functions

babel-bot opened this issue · comments

Original issue submitted by @julien-f in babel/babel#2988

const getConsole = () => console

const log = ::getConsole().log // Binding should be performed on object property
commented

Hey @babel-bot! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community that typically always has someone willing to help. You can sign-up here
for an invite.

We should verify if this is actually against the spec. The spec has

BindExpression[Yield] :
    LeftHandSideExpression[?Yield] :: [lookahead ≠ new] MemberExpression[?Yield]
    :: MemberExpression[?Yield]

and MemberExpression from the grammar side of things (rather than the AST side), does not include reading a property off the result of a call.

@loganfsmyth, I think you're right about your reading of the spec, but that's plausibly a bug in the grammar in the proposal - it's easy to forget that CallExpression has its own production for property access which also needs to be thought about any time you work with property access. (We ran into this in the private fields proposal, e.g.)

Totally.

This issue has been moved to babel/babel#6674.