Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

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

Closed
ctulek opened this Issue Aug 8, 2011 · 7 comments

Comments

Projects
None yet
5 participants

ctulek commented Aug 8, 2011

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 commented Sep 28, 2012

"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

Contributor

einars commented Sep 28, 2012

@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 commented Oct 11, 2012

Ah, good point.

Contributor

einars commented Feb 6, 2013

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

@einars einars closed this Feb 6, 2013

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.

Contributor

bitwiseman commented Feb 28, 2014

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

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