Skip to content
This repository

"default" keyword in object declarations indented like switch/case default #61

Closed
ctulek opened this Issue August 08, 2011 · 7 comments

5 participants

Cagdas Tulek Einar Lielmanis k3n Nathan Friedly Liam Newman
Cagdas Tulek

var a = {
x:5,
y:6,
hello: "world",
default: true
}

is indented as

var a = {
x: 5,
y: 6,
hello: "world",
default:
true
}
it should be
var a = {
x: 5,
y: 6,
hello: "world",
default: true
}

k3n

"Default" is a reserved word[1], and thus you should probably not use it -- at least unquoted. I'm curious, what happens if you quote it as a string? It shouldn't be seen as a reserved word in that case.

https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Reserved_Words

Einar Lielmanis
Owner

@k3n: even though "default" is a reserved word, this:

var a = { default: 42 };
print(a.default)

still is a perfectly fine and correct syntax, see "Reserved word syntax" in the same link you mentioned.

k3n
k3n commented October 11, 2012

Ah, good point.

Einar Lielmanis
Owner

This seems to be fixed automagically (switches don't move their case's/default's around anymore), closing

Einar Lielmanis einars closed this February 06, 2013
Nathan Friedly

I know this is an old, closed issue, but it looks like chevex/yargs#8 is related to the same bug, but this time because a reserved word is being called a.import-style. But, per that doc, it should also be allowed.

If you'd like, I can open up a new ticket.

Liam Newman
Collaborator

FYI, we also have multiple open issues already tracking this. Thanks!

Nathan Friedly

Oh, sorry, this was the first one that the github search brought up that looked appropriate. Thanks for the update though :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.