Skip to content

Commit

Permalink
support catch without error (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
LongTengDao authored Aug 31, 2022
1 parent 1f77749 commit eb1ce8c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function findGlobals(source, options) {
},
'Class': declareClass,
'TryStatement': function (node) {
if (node.handler === null) return;
if (node.handler === null || node.handler.param === null) return;
node.handler.locals = node.handler.locals || Object.create(null);
declarePattern(node.handler.param, node.handler);
},
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/catch-without-error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
try{}catch{}
3 changes: 3 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ test('assign_implicit.js - assign from an implicit global', function () {
test('catch-pattern.js - pattern in catch', function () {
assert.deepEqual(detect(read('catch-pattern.js')), []);
});
test('catch-without-error.js - catch without error', function () {
assert.deepEqual(detect(read('catch-without-error.js')), []);
});
test('class.js - ES2015 classes', function () {
assert.deepEqual(detect(read('class.js')).map(nameOf), ['G', 'OtherClass_', 'SuperClass', 'this'].sort());
});
Expand Down

0 comments on commit eb1ce8c

Please sign in to comment.