Skip to content

Commit 29284cb

Browse files
committed
Merge branch 'master' into errorOnWithStatement
2 parents ed3d740 + d10f2e7 commit 29284cb

File tree

54 files changed

+63
-69
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+63
-69
lines changed

src/compiler/parser.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1836,7 +1836,12 @@ module ts {
18361836
if (token === SyntaxKind.OpenParenToken || token === SyntaxKind.LessThanToken) {
18371837
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken);
18381838
var body = parseBody(/* ignoreMissingOpenBrace */ false);
1839-
node.initializer = makeFunctionExpression(SyntaxKind.FunctionExpression, node.pos, node.name, sig, body);
1839+
// do not propagate property name as name for function expression
1840+
// for scenarios like
1841+
// var x = 1;
1842+
// var y = { x() { } }
1843+
// otherwise this will bring y.x into the scope of x which is incorrect
1844+
node.initializer = makeFunctionExpression(SyntaxKind.FunctionExpression, node.pos, undefined, sig, body);
18401845
}
18411846
else {
18421847
parseExpected(SyntaxKind.ColonToken);

tests/baselines/reference/assignEveryTypeToAny.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ var h;
9090
x = h;
9191
var i;
9292
x = i;
93-
x = { f: function f() {
93+
x = { f: function () {
9494
return 1;
9595
} };
96-
x = { f: function f(x) {
96+
x = { f: function (x) {
9797
return x;
9898
} };
9999
function j(a) {

tests/baselines/reference/assignmentCompatWithCallSignatures2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ t = { f: function (x) { return 1; } };
6666
t = { f: function f() {
6767
return 1;
6868
} };
69-
t = { f: function f(x) {
69+
t = { f: function (x) {
7070
return '';
7171
} };
7272
a = { f: function () { return 1; } };

tests/baselines/reference/assignmentToObjectAndFunction.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ var badFundule: Function = bad; // error
3232
//// [assignmentToObjectAndFunction.js]
3333
var errObj = { toString: 0 };
3434
var goodObj = {
35-
toString: function toString(x) {
35+
toString: function (x) {
3636
return "";
3737
}
3838
};

tests/baselines/reference/callSignaturesWithAccessibilityModifiersOnParameters.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ var C = (function () {
7272
})();
7373
var a;
7474
var b = {
75-
foo: function foo(x, y) {
75+
foo: function (x, y) {
7676
},
7777
a: function foo(x, y) {
7878
},

tests/baselines/reference/callSignaturesWithDuplicateParameters.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ var C = (function () {
7272
})();
7373
var a;
7474
var b = {
75-
foo: function foo(x, x) {
75+
foo: function (x, x) {
7676
},
7777
a: function foo(x, x) {
7878
},

tests/baselines/reference/callSignaturesWithOptionalParameters.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ a(1);
8989
a.foo();
9090
a.foo(1);
9191
var b = {
92-
foo: function foo(x) {
92+
foo: function (x) {
9393
},
9494
a: function foo(x, y) {
9595
},

tests/baselines/reference/callSignaturesWithParameterInitializers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ a(1);
9595
a.foo();
9696
a.foo(1);
9797
var b = {
98-
foo: function foo(x) {
98+
foo: function (x) {
9999
if (x === void 0) { x = 1; }
100100
},
101101
a: function foo(x, y) {

tests/baselines/reference/genericsWithoutTypeParameters1.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function foo(x, y) {
5151
function foo2(x, y) {
5252
}
5353
var x = { a: new C() };
54-
var x2 = { a: { bar: function bar() {
54+
var x2 = { a: { bar: function () {
5555
return 1;
5656
} } };
5757
var D = (function () {

tests/baselines/reference/invalidUndefinedValues.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ var M;
5454
M.x = 1;
5555
})(M || (M = {}));
5656
x = M;
57-
x = { f: function f() {
57+
x = { f: function () {
5858
} };
5959
function f(a) {
6060
x = a;

0 commit comments

Comments
 (0)