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.
|
// places too. :-( Wish JS had multiple inheritance.
|
||||||
throw def;
|
throw def;
|
||||||
});
|
});
|
||||||
|
def(AST_Arrow, function() {
|
||||||
|
throw def;
|
||||||
|
});
|
||||||
function ev(node, compressor) {
|
function ev(node, compressor) {
|
||||||
if (!compressor) throw new Error("Compressor must be passed");
|
if (!compressor) throw new Error("Compressor must be passed");
|
||||||
|
|
||||||
@@ -756,7 +759,8 @@ merge(Compressor.prototype, {
|
|||||||
case "typeof":
|
case "typeof":
|
||||||
// Function would be evaluated to an array and so typeof would
|
// Function would be evaluated to an array and so typeof would
|
||||||
// incorrectly return 'object'. Hence making is a special case.
|
// 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);
|
e = ev(e, compressor);
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,16 @@ regression_arrow_functions_and_hoist: {
|
|||||||
expect_exact: "a=>b;"
|
expect_exact: "a=>b;"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typeof_arrow_functions: {
|
||||||
|
options = {
|
||||||
|
evaluate: true
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
typeof (x) => null;
|
||||||
|
}
|
||||||
|
expect_exact: "\"function\";"
|
||||||
|
}
|
||||||
|
|
||||||
destructuring_arguments: {
|
destructuring_arguments: {
|
||||||
input: {
|
input: {
|
||||||
(function ( a ) { });
|
(function ( a ) { });
|
||||||
|
|||||||
Reference in New Issue
Block a user