Merge pull request #773 from fabiosantoscode/harmony-typeof-arrows
Fix evaluating the typeof an arrow function.
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -36,6 +36,16 @@ regression_arrow_functions_and_hoist: {
|
||||
expect_exact: "a=>b;"
|
||||
}
|
||||
|
||||
typeof_arrow_functions: {
|
||||
options = {
|
||||
evaluate: true
|
||||
}
|
||||
input: {
|
||||
typeof (x) => null;
|
||||
}
|
||||
expect_exact: "\"function\";"
|
||||
}
|
||||
|
||||
destructuring_arguments: {
|
||||
input: {
|
||||
(function ( a ) { });
|
||||
|
||||
Reference in New Issue
Block a user