diff --git a/escodegen.js b/escodegen.js index a8d0170c..8772c1f9 100644 --- a/escodegen.js +++ b/escodegen.js @@ -1176,15 +1176,19 @@ withIndent(function () { var guard; - result = [ - 'catch' + space + '(', - that.generateExpression(stmt.param, Precedence.Sequence, E_TTT), - ')' - ]; + if (!stmt.param) { + result = ['catch']; + } else { + result = [ + 'catch' + space + '(', + that.generateExpression(stmt.param, Precedence.Sequence, E_TTT), + ')' + ]; - if (stmt.guard) { - guard = that.generateExpression(stmt.guard, Precedence.Sequence, E_TTT); - result.splice(2, 0, ' if ', guard); + if (stmt.guard) { + guard = that.generateExpression(stmt.guard, Precedence.Sequence, E_TTT); + result.splice(2, 0, ' if ', guard); + } } }); result.push(this.maybeBlock(stmt.body, S_TFFF)); diff --git a/test/test.js b/test/test.js index a21cd487..d4df3995 100644 --- a/test/test.js +++ b/test/test.js @@ -13320,6 +13320,44 @@ data = { expression: false }] } + }, + + 'try { } catch { }': { + type: 'TryStatement', + block: { + type: 'BlockStatement', + body: [], + range: [4, 7], + loc: { + start: { line: 1, column: 4 }, + end: { line: 1, column: 7 } + } + }, + handlers: [{ + type: 'CatchClause', + param: null, + guard: null, + body: { + type: 'BlockStatement', + body: [], + range: [14, 17], + loc: { + start: { line: 1, column: 14 }, + end: { line: 1, column: 17 } + } + }, + range: [8, 17], + loc: { + start: { line: 1, column: 8 }, + end: { line: 1, column: 17 } + } + }], + finalizer: null, + range: [0, 17], + loc: { + start: { line: 1, column: 0 }, + end: { line: 1, column: 17 } + } } },