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

FR: Allow property setting shorthand (for objects literals) with 'multiple dots' access #301

Closed
ymeine opened this issue Apr 22, 2013 · 2 comments

Comments

@ymeine
Copy link

ymeine commented Apr 22, 2013

Hi all,

I like the property setting shorthand feature for object literals, which is (to remind you):

{
    a
    b
    c.x
    c.y
}

compiling to

{
  a: a,
  b: b,
  x: c.x,
  y: c.y
}

However, I've been surprised not being able to do something like:

{
    a.b.c
    x.y.z
}

to compile to

{
    c: a.b.c,
    z: x.y.z
}

as this however seems intuitive: simply take the last part of the property access as the property name, like (whatever-I-do-to-reach-the-value).property, giving property: (whatever-I-do-to-reach-the-value).property.

With a real example:

{
    JSON.parse input .property
}

would give:

{
    property: JSON.parse(input).property
}

FYI, the first non-working example I gave you (with simple multiple dots access) triggers the following error: Parse error on line 2: Unexpected 'DOT'

While the last one gives: Parse error on line 2: Unexpected 'CALL('

Best regards

@vendethiel
Copy link
Contributor

satyr/coco#163

@rhendric
Copy link
Collaborator

rhendric commented Aug 7, 2018

Implemented in #958.

@rhendric rhendric closed this as completed Aug 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants