Fix evaluating the typeof an arrow function. Using evaluate on used to cause a crash.

This commit is contained in:
Fábio Santos
2015-08-14 22:05:42 +01:00
parent 56c0b834d6
commit dcce4e5c66
2 changed files with 15 additions and 1 deletions

View File

@@ -738,6 +738,9 @@ merge(Compressor.prototype, {
// places too. :-( Wish JS had multiple inheritance.
throw def;
});
def(AST_Arrow, function() {
throw def;
});
function ev(node, compressor) {
if (!compressor) throw new Error("Compressor must be passed");
@@ -756,7 +759,8 @@ merge(Compressor.prototype, {
case "typeof":
// Function would be evaluated to an array and so typeof would
// incorrectly return 'object'. Hence making is a special case.
if (e instanceof AST_Function) return typeof function(){};
if (e instanceof AST_Function ||
e instanceof AST_Arrow) return typeof function(){};
e = ev(e, compressor);