Skip to content

Commit

Permalink
Fix #4451: Treat default as a keyword in an export statement only w…
Browse files Browse the repository at this point in the history
…hen it follows `export` or `as`
  • Loading branch information
GeoffreyBooth committed Apr 3, 2017
1 parent ca0fd22 commit 98d1644
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
12 changes: 6 additions & 6 deletions lib/coffee-script/lexer.js

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

2 changes: 1 addition & 1 deletion src/lexer.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ exports.Lexer = class Lexer
if id is 'as' and @seenExport and @tag() is 'IDENTIFIER'
@token 'AS', id
return id.length
if id is 'default' and @seenExport
if id is 'default' and @seenExport and @tag() in ['EXPORT', 'AS']
@token 'DEFAULT', id
return id.length

Expand Down
8 changes: 8 additions & 0 deletions test/modules.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -749,3 +749,11 @@ test "#4394: export shouldn't prevent variable declarations", ->
};
"""
eq toJS(input), output

test "#4451: `default` in an export statement is only treated as a keyword when it follows `export` or `as`", ->
input = "export default { default: 1 }"
output = """
export default {
"default": 1
};
"""

0 comments on commit 98d1644

Please sign in to comment.