Skip to content

Commit c4b22d3

Browse files
committed
Emit comments for expression statements
1 parent 0a75cc2 commit c4b22d3

File tree

395 files changed

+1771
-1438
lines changed

Some content is hidden

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

395 files changed

+1771
-1438
lines changed

src/compiler/emitter.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -917,10 +917,12 @@ module ts {
917917

918918
function emitExpressionStatement(node: ExpressionStatement) {
919919
var isArrowExpression = node.expression.kind === SyntaxKind.ArrowFunction;
920+
emitLeadingComments(node);
920921
if (isArrowExpression) write("(");
921922
emit(node.expression);
922923
if (isArrowExpression) write(")");
923924
write(";");
925+
emitTrailingComments(node);
924926
}
925927

926928
function emitIfStatement(node: IfStatement) {

tests/baselines/reference/aliasAssignments.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ exports.someClass = someClass;
2323
//// [aliasAssignments_1.js]
2424
var moduleA = require("aliasAssignments_moduleA");
2525
var x = moduleA;
26-
x = 1;
26+
x = 1; // Should be error
2727
var y = 1;
28-
y = moduleA;
28+
y = moduleA; // should be error

tests/baselines/reference/aliasOnMergedModuleInterface.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ var x: foo.A = foo.bar("hello"); // foo.A should be ok but foo.bar should be err
2424
//// [aliasOnMergedModuleInterface_0.js]
2525
//// [aliasOnMergedModuleInterface_1.js]
2626
var z;
27-
z.bar("hello");
27+
z.bar("hello"); // This should be ok
2828
var x = foo.bar("hello"); // foo.A should be ok but foo.bar should be error

tests/baselines/reference/aliasUsedAsNameValue.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@ exports.b = b;
3131
var mod = require("aliasUsedAsNameValue_0");
3232
var b = require("aliasUsedAsNameValue_1");
3333
exports.a = function () {
34+
//var x = mod.id; // TODO needed hack that mod is loaded
3435
b.b(mod);
3536
};

tests/baselines/reference/ambiguousCallsWhereReturnTypesAgree.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ var TestClass = (function () {
3535
TestClass.prototype.bar = function (x) {
3636
};
3737
TestClass.prototype.foo = function (x) {
38-
this.bar(x);
38+
this.bar(x); // should not error
3939
};
4040
return TestClass;
4141
})();

tests/baselines/reference/argumentsBindsToFunctionScopeArgumentList.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ function foo(a) {
77
//// [argumentsBindsToFunctionScopeArgumentList.js]
88
var arguments = 10;
99
function foo(a) {
10-
arguments = 10;
10+
arguments = 10; /// This shouldnt be of type number and result in error.
1111
}

tests/baselines/reference/arithAssignTyping.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ var f = (function () {
2020
}
2121
return f;
2222
})();
23-
f += '';
24-
f += 1;
25-
f -= 1;
26-
f *= 1;
27-
f /= 1;
28-
f %= 1;
29-
f &= 1;
30-
f |= 1;
31-
f <<= 1;
32-
f >>= 1;
33-
f >>>= 1;
34-
f ^= 1;
23+
f += ''; // error
24+
f += 1; // error
25+
f -= 1; // error
26+
f *= 1; // error
27+
f /= 1; // error
28+
f %= 1; // error
29+
f &= 1; // error
30+
f |= 1; // error
31+
f <<= 1; // error
32+
f >>= 1; // error
33+
f >>>= 1; // error
34+
f ^= 1; // error

tests/baselines/reference/arrayAssignmentTest1.js

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -153,29 +153,32 @@ var i1_error = []; // should be an error - is
153153
var c1_error = []; // should be an error - is
154154
var c2_error = []; // should be an error - is
155155
var c3_error = []; // should be an error - is
156-
arr_any = arr_i1;
157-
arr_any = arr_c1;
158-
arr_any = arr_c2;
159-
arr_any = arr_c3;
160-
arr_i1 = arr_i1;
161-
arr_i1 = arr_c1;
162-
arr_i1 = arr_c2;
163-
arr_i1 = arr_c3;
164-
arr_c1 = arr_c1;
165-
arr_c1 = arr_c2;
166-
arr_c1 = arr_i1;
167-
arr_c1 = arr_c3;
168-
arr_c2 = arr_c2;
169-
arr_c2 = arr_c1;
170-
arr_c2 = arr_i1;
171-
arr_c2 = arr_c3;
172-
arr_c3 = arr_c2_2;
173-
arr_c3 = arr_c1_2;
174-
arr_c3 = arr_i1_2;
175-
arr_any = f1;
176-
arr_any = o1;
177-
arr_any = a1;
178-
arr_any = c1;
179-
arr_any = c2;
180-
arr_any = c3;
181-
arr_any = i1;
156+
arr_any = arr_i1; // should be ok - is
157+
arr_any = arr_c1; // should be ok - is
158+
arr_any = arr_c2; // should be ok - is
159+
arr_any = arr_c3; // should be ok - is
160+
arr_i1 = arr_i1; // should be ok - subtype relationship - is
161+
arr_i1 = arr_c1; // should be ok - subtype relationship - is
162+
arr_i1 = arr_c2; // should be ok - subtype relationship - is
163+
arr_i1 = arr_c3; // should be an error - is
164+
arr_c1 = arr_c1; // should be ok - subtype relationship - is
165+
arr_c1 = arr_c2; // should be ok - subtype relationship - is
166+
arr_c1 = arr_i1; // should be an error - is
167+
arr_c1 = arr_c3; // should be an error - is
168+
arr_c2 = arr_c2; // should be ok - subtype relationship - is
169+
arr_c2 = arr_c1; // should be an error - subtype relationship - is
170+
arr_c2 = arr_i1; // should be an error - subtype relationship - is
171+
arr_c2 = arr_c3; // should be an error - is
172+
// "clean up bug" occurs at this point
173+
// if you move these three expressions to another file, they raise an error
174+
// something to do with state from the above propagating forward?
175+
arr_c3 = arr_c2_2; // should be an error - is
176+
arr_c3 = arr_c1_2; // should be an error - is
177+
arr_c3 = arr_i1_2; // should be an error - is
178+
arr_any = f1; // should be an error - is
179+
arr_any = o1; // should be an error - is
180+
arr_any = a1; // should be ok - is
181+
arr_any = c1; // should be an error - is
182+
arr_any = c2; // should be an error - is
183+
arr_any = c3; // should be an error - is
184+
arr_any = i1; // should be an error - is

tests/baselines/reference/arrayAssignmentTest2.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -123,16 +123,17 @@ var arr_i1_2 = [];
123123
var arr_c1_2 = [];
124124
var arr_c2_2 = [];
125125
var arr_c3 = [];
126-
arr_c3 = arr_c2_2;
127-
arr_c3 = arr_c1_2;
128-
arr_c3 = arr_i1_2;
129-
arr_any = f1;
126+
// "clean up error" occurs at this point
127+
arr_c3 = arr_c2_2; // should be an error - is
128+
arr_c3 = arr_c1_2; // should be an error - is
129+
arr_c3 = arr_i1_2; // should be an error - is
130+
arr_any = f1; // should be an error - is
130131
arr_any = function () {
131132
return null;
132-
};
133-
arr_any = o1;
134-
arr_any = a1;
135-
arr_any = c1;
136-
arr_any = c2;
137-
arr_any = c3;
138-
arr_any = i1;
133+
}; // should be an error - is
134+
arr_any = o1; // should be an error - is
135+
arr_any = a1; // should be ok - is
136+
arr_any = c1; // should be an error - is
137+
arr_any = c2; // should be an error - is
138+
arr_any = c3; // should be an error - is
139+
arr_any = i1; // should be an error - is

tests/baselines/reference/arrayAssignmentTest4.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,5 @@ var o1 = { one: 1 };
5151
var arr_any = [];
5252
arr_any = function () {
5353
return null;
54-
};
55-
arr_any = c3;
54+
}; // should be an error - is
55+
arr_any = c3; // should be an error - is

0 commit comments

Comments
 (0)