CR feedback.
This commit is contained in:
parent
53ed427e0d
commit
8d0dc91d64
|
@ -3959,6 +3959,21 @@ module ts {
|
|||
// NOTE(cyrusn): Some expressions may seem to be side effect free, but may
|
||||
// actually have side effects. For example, a binary + expression may cause
|
||||
// the toString method to be called on value, which may have side effects.
|
||||
|
||||
// These are the set of syntactic productions which we know could definitely
|
||||
// have side effects:
|
||||
case SyntaxKind.CallExpression:
|
||||
case SyntaxKind.NewExpression:
|
||||
return true;
|
||||
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
case SyntaxKind.ElementAccessExpression:
|
||||
// Property/Element access might end up causing an accessor to run. As
|
||||
// such, we have to assume there will be side effects.
|
||||
return true;
|
||||
|
||||
// These are the set of syntactic productions which we know definitely do not
|
||||
// have side effects:
|
||||
case SyntaxKind.StringLiteral:
|
||||
case SyntaxKind.NoSubstitutionTemplateLiteral:
|
||||
case SyntaxKind.NumericLiteral:
|
||||
|
@ -3975,6 +3990,8 @@ module ts {
|
|||
case SyntaxKind.SetAccessor:
|
||||
return false;
|
||||
|
||||
// These constructs may or may not have side effects depending on their
|
||||
// constituent children.
|
||||
case SyntaxKind.ArrayBindingPattern:
|
||||
case SyntaxKind.ObjectBindingPattern:
|
||||
return forEach((<BindingPattern>node).elements, hasPossibleSideEffects);
|
||||
|
@ -3987,16 +4004,9 @@ module ts {
|
|||
return hasPossibleSideEffects((<ParameterDeclaration>node).name) ||
|
||||
hasPossibleSideEffects((<ParameterDeclaration>node).initializer);
|
||||
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
return hasPossibleSideEffects((<PropertyAccessExpression>node).expression);
|
||||
|
||||
case SyntaxKind.ArrayLiteralExpression:
|
||||
return forEach((<ArrayLiteralExpression>node).elements, hasPossibleSideEffects);
|
||||
|
||||
case SyntaxKind.ElementAccessExpression:
|
||||
return hasPossibleSideEffects((<ElementAccessExpression>node).expression) ||
|
||||
hasPossibleSideEffects((<ElementAccessExpression>node).argumentExpression);
|
||||
|
||||
case SyntaxKind.ParenthesizedExpression:
|
||||
return hasPossibleSideEffects((<ParenthesizedExpression>node).expression);
|
||||
|
||||
|
|
|
@ -8,6 +8,9 @@ function bar(a = v[0]) {
|
|||
|
||||
//// [functionWithDefaultParameterWithNoStatements11.js]
|
||||
var v;
|
||||
function foo(a) { }
|
||||
function bar(a) {
|
||||
function foo(a) {
|
||||
if (a === void 0) { a = v[0]; }
|
||||
}
|
||||
function bar(a) {
|
||||
if (a === void 0) { a = v[0]; }
|
||||
}
|
||||
|
|
|
@ -5,6 +5,9 @@ function bar(a = console.log) {
|
|||
}
|
||||
|
||||
//// [functionWithDefaultParameterWithNoStatements9.js]
|
||||
function foo(a) { }
|
||||
function bar(a) {
|
||||
function foo(a) {
|
||||
if (a === void 0) { a = console.log; }
|
||||
}
|
||||
function bar(a) {
|
||||
if (a === void 0) { a = console.log; }
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue