support BigInt literals (#4583)
This commit is contained in:
@@ -689,32 +689,32 @@ function OutputStream(options) {
|
||||
|
||||
PARENS(AST_Sequence, function(output) {
|
||||
var p = output.parent();
|
||||
// [ 1, (2, 3), 4 ] ==> [ 1, 3, 4 ]
|
||||
// [ 1, (2, 3), 4 ] ---> [ 1, 3, 4 ]
|
||||
return p instanceof AST_Array
|
||||
// () => (foo, bar)
|
||||
// () ---> (foo, bar)
|
||||
|| is_arrow(p) && p.value === this
|
||||
// await (foo, bar)
|
||||
|| p instanceof AST_Await
|
||||
// 1 + (2, 3) + 4 ==> 8
|
||||
// 1 + (2, 3) + 4 ---> 8
|
||||
|| p instanceof AST_Binary
|
||||
// new (foo, bar) or foo(1, (2, 3), 4)
|
||||
|| p instanceof AST_Call
|
||||
// (false, true) ? (a = 10, b = 20) : (c = 30)
|
||||
// ==> 20 (side effect, set a := 10 and b := 20)
|
||||
// ---> 20 (side effect, set a := 10 and b := 20)
|
||||
|| p instanceof AST_Conditional
|
||||
// [ a = (1, 2) ] = [] ==> a == 2
|
||||
// [ a = (1, 2) ] = [] ---> a == 2
|
||||
|| p instanceof AST_DefaultValue
|
||||
// { [(1, 2)]: 3 }[2] ==> 3
|
||||
// { foo: (1, 2) }.foo ==> 2
|
||||
// { [(1, 2)]: 3 }[2] ---> 3
|
||||
// { foo: (1, 2) }.foo ---> 2
|
||||
|| p instanceof AST_DestructuredKeyVal
|
||||
|| p instanceof AST_ObjectProperty
|
||||
// (1, {foo:2}).foo or (1, {foo:2})["foo"] ==> 2
|
||||
// (1, {foo:2}).foo or (1, {foo:2})["foo"] ---> 2
|
||||
|| p instanceof AST_PropAccess && p.expression === this
|
||||
// ...(foo, bar, baz)
|
||||
|| p instanceof AST_Spread
|
||||
// !(foo, bar, baz)
|
||||
|| p instanceof AST_Unary
|
||||
// var a = (1, 2), b = a + a; ==> b == 4
|
||||
// var a = (1, 2), b = a + a; ---> b == 4
|
||||
|| p instanceof AST_VarDef;
|
||||
});
|
||||
|
||||
@@ -777,14 +777,10 @@ function OutputStream(options) {
|
||||
});
|
||||
|
||||
PARENS(AST_Number, function(output) {
|
||||
if (!output.option("galio")) return false;
|
||||
// https://github.com/mishoo/UglifyJS/pull/1009
|
||||
var p = output.parent();
|
||||
if (p instanceof AST_PropAccess && p.expression === this) {
|
||||
var value = this.value;
|
||||
// https://github.com/mishoo/UglifyJS/issues/115
|
||||
return value < 0
|
||||
// https://github.com/mishoo/UglifyJS/pull/1009
|
||||
|| output.option("galio") && /^0/.test(make_num(value));
|
||||
}
|
||||
return p instanceof AST_PropAccess && p.expression === this && /^0/.test(make_num(this.value));
|
||||
});
|
||||
|
||||
function needs_parens_assign_cond(self, output) {
|
||||
@@ -807,8 +803,8 @@ function OutputStream(options) {
|
||||
});
|
||||
PARENS(AST_Assign, function(output) {
|
||||
if (needs_parens_assign_cond(this, output)) return true;
|
||||
// v8 parser bug => workaround
|
||||
// f([1], [a] = []) => f([1], ([a] = []))
|
||||
// v8 parser bug ---> workaround
|
||||
// f([1], [a] = []) ---> f([1], ([a] = []))
|
||||
if (output.option("v8")) return this.left instanceof AST_Destructured;
|
||||
// ({ p: a } = o);
|
||||
if (this.left instanceof AST_DestructuredObject) return needs_parens_obj(output);
|
||||
|
||||
Reference in New Issue
Block a user