From 0b303379c0cdc33a8c14c97ab29148d981b4887e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dar=C3=ADo=20Javier=20Cravero?= Date: Thu, 4 Feb 2016 21:54:21 +0000 Subject: [PATCH] fix: don't fail if definition is undefined Running `uglifyjs --verbose --compress --mangle --screw-ie8 class.js` with `class.js`: ``` class Foo { bar() { } } ``` Fails with: ``` undefined:4041 return this.definition().unmangleable(options); TypeError: Cannot read property 'unmangleable' of undefined ... ``` --- lib/scope.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/scope.js b/lib/scope.js index ac58ad80..371afb2b 100644 --- a/lib/scope.js +++ b/lib/scope.js @@ -350,7 +350,8 @@ AST_Scope.DEFMETHOD("references", function(sym){ }); AST_Symbol.DEFMETHOD("unmangleable", function(options){ - return this.definition().unmangleable(options); + var def = this.definition(); + return def && def.unmangleable(options); }); // property accessors are not mangleable