assert(FormatTok->isOneOf(Keywords.kw_import, tok::kw_export));
nextToken();
- if (FormatTok->isOneOf(tok::kw_const, tok::kw_class, Keywords.kw_function,
- Keywords.kw_var))
+ // Consume "function" and "default function", so that these get parsed as
+ // free-standing JS functions, i.e. do not require a trailing semicolon.
+ if (FormatTok->is(tok::kw_default))
+ nextToken();
+ if (FormatTok->is(Keywords.kw_function)) {
+ nextToken();
+ return;
+ }
+
+ if (FormatTok->isOneOf(tok::kw_const, tok::kw_class, Keywords.kw_var))
return; // Fall through to parsing the corresponding structure.
if (FormatTok->is(tok::kw_default)) {
verifyFormat("export function fn() {\n"
" return 'fn';\n"
"}");
+ verifyFormat("export function A() {\n"
+ "}\n"
+ "export default function B() {\n"
+ "}\n"
+ "export function C() {\n"
+ "}");
verifyFormat("export const x = 12;");
verifyFormat("export default class X {}");
verifyFormat("export {X, Y} from 'some/module.js';");