Merge pull request #773 from fabiosantoscode/harmony-typeof-arrows

Fix evaluating the typeof an arrow function.
This commit is contained in:
Richard van Velzen
2015-08-21 11:51:42 +02:00
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);