Skip to content

Commit

Permalink
Backport #4783, fix for export default followed by an implicit obje…
Browse files Browse the repository at this point in the history
…ct (#4800)
  • Loading branch information
GeoffreyBooth committed Nov 29, 2017
1 parent f301b04 commit 8bb89d8
Show file tree
Hide file tree
Showing 7 changed files with 137 additions and 116 deletions.
2 changes: 2 additions & 0 deletions lib/coffee-script/grammar.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/coffee-script/lexer.js

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

10 changes: 5 additions & 5 deletions lib/coffee-script/nodes.js

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

215 changes: 107 additions & 108 deletions lib/coffee-script/parser.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/grammar.coffee
Expand Up @@ -396,6 +396,7 @@ grammar =
o 'EXPORT Identifier = INDENT Expression OUTDENT', -> new ExportNamedDeclaration new Assign $2, $5, null,
moduleDeclaration: 'export'
o 'EXPORT DEFAULT Expression', -> new ExportDefaultDeclaration $3
o 'EXPORT DEFAULT INDENT Object OUTDENT', -> new ExportDefaultDeclaration new Value $4
o 'EXPORT EXPORT_ALL FROM String', -> new ExportAllDeclaration new Literal($2), $4
o 'EXPORT { ExportSpecifierList OptComma } FROM String', -> new ExportNamedDeclaration new ExportSpecifierList($3), $7
]
Expand Down
2 changes: 1 addition & 1 deletion src/lexer.coffee
Expand Up @@ -1096,4 +1096,4 @@ INDENTABLE_CLOSERS = [')', '}', ']']
# Tokens that, when appearing at the end of a line, suppress a following TERMINATOR/INDENT token
UNFINISHED = ['\\', '.', '?.', '?::', 'UNARY', 'MATH', 'UNARY_MATH', '+', '-',
'**', 'SHIFT', 'RELATION', 'COMPARE', '&', '^', '|', '&&', '||',
'BIN?', 'THROW', 'EXTENDS', 'DEFAULT']
'BIN?', 'THROW', 'EXTENDS']
21 changes: 20 additions & 1 deletion test/modules.coffee
Expand Up @@ -359,7 +359,7 @@ test "export default implicit object", ->
test "export default multiline implicit object", ->
input = """
export default
foo: 'bar',
foo: 'bar'
baz: 'qux'
"""
output = """
Expand All @@ -369,6 +369,25 @@ test "export default multiline implicit object", ->
};"""
eq toJS(input), output

test "export default multiline implicit object with internal braces", ->
input = """
export default
foo: yes
bar: {
baz
}
quz: no
"""
output = """
export default {
foo: true,
bar: {
baz: baz
},
quz: false
};"""
eq toJS(input), output

test "export default assignment expression", ->
input = "export default foo = 'bar'"
output = """
Expand Down

0 comments on commit 8bb89d8

Please sign in to comment.