NaN and Infinity were replaced in the output generation, instead of
during compression. This could lead to results where `1/0` was inserted
without parens leading to invalid output.

The nodes are replaced in the compression step now, and the output
generation returns their regular names. This should not be a problem,
since they're already only constructed from the original name.
This commit is contained in:
Richard van Velzen
2014-12-31 12:23:00 +01:00
parent 5538ec7bd8
commit c75f5a1fd8
3 changed files with 45 additions and 10 deletions

View File

@@ -549,12 +549,6 @@ function OutputStream(options) {
return true;
});
PARENS(AST_NaN, function(output){
var p = output.parent();
if (p instanceof AST_PropAccess && p.expression === this)
return true;
});
PARENS([ AST_Assign, AST_Conditional ], function (output){
var p = output.parent();
// !(a = false) → true
@@ -1109,10 +1103,10 @@ function OutputStream(options) {
});
DEFPRINT(AST_Hole, noop);
DEFPRINT(AST_Infinity, function(self, output){
output.print("1/0");
output.print("Infinity");
});
DEFPRINT(AST_NaN, function(self, output){
output.print("0/0");
output.print("NaN");
});
DEFPRINT(AST_This, function(self, output){
output.print("this");