Skip to content

[CS2] JavaScript keywords used as properties no longer require quoting #4527

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

Merged
merged 1 commit into from
Apr 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/coffeescript/browser.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/coffeescript/cake.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/coffeescript/coffeescript.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions lib/coffeescript/command.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 24 additions & 31 deletions lib/coffeescript/nodes.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions lib/coffeescript/optparse.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/coffeescript/repl.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 1 addition & 7 deletions src/nodes.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -951,10 +951,7 @@ exports.Access = class Access extends Base
name = @name.compileToFragments o
node = @name.unwrap()
if node instanceof PropertyName
if node.value in JS_FORBIDDEN
[@makeCode('["'), name..., @makeCode('"]')]
else
[@makeCode('.'), name...]
[@makeCode('.'), name...]
else
[@makeCode('['), name..., @makeCode(']')]

Expand Down Expand Up @@ -1781,9 +1778,6 @@ exports.Assign = class Assign extends Base
if @variable.shouldCache()
compiledName.unshift @makeCode '['
compiledName.push @makeCode ']'
else if fragmentsToText(compiledName) in JS_FORBIDDEN
compiledName.unshift @makeCode '"'
compiledName.push @makeCode '"'
return compiledName.concat @makeCode(": "), val

answer = compiledName.concat @makeCode(" #{ @context or '=' } "), val
Expand Down
2 changes: 1 addition & 1 deletion test/modules.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ test "#4451: `default` in an export statement is only treated as a keyword when
input = "export default { default: 1 }"
output = """
export default {
"default": 1
default: 1
};
"""
eq toJS(input), output
Expand Down