Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix name generation scoping #58418

Merged
merged 2 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
206 changes: 103 additions & 103 deletions src/compiler/emitter.ts

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions src/testRunner/unittests/evaluation/asyncArrow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,29 @@ describe("unittests:: evaluation:: asyncArrowEvaluation", () => {
await result.main();
assert.instanceOf(result.output[0].a(), result.A);
});

// https://github.com/microsoft/TypeScript/issues/57897
it("Class alias (es5)", async () => {
const result = evaluator.evaluateTypeScript(`
class X {
public static a = async (someVar: boolean = true) => {
return await X.b();
};

public static b = async () => {
return "GOOD";
};
}

export async function main() {
try {
return await X.a();
}
catch (e) {
return "BAD";
}
}`);
const output = await result.main();
assert.equal(output, "GOOD");
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,17 @@ function f12() { return (...args_1) => {
function f() {
const a1 = (x_1, ...args_1) => __awaiter(this, [x_1, ...args_1], void 0, function* (x, y = z) { });
const a2 = (_a) => __awaiter(this, [_a], void 0, function* ({ [z]: x }) { });
const a3 = (...args_2) => {
const a3 = (...args_1) => {
var arguments_10 = arguments;
return __awaiter(this, [...args_2], void 0, function* (x = z) { return () => __awaiter(this, void 0, void 0, function* () { return arguments_10; }); });
return __awaiter(this, [...args_1], void 0, function* (x = z) { return () => __awaiter(this, void 0, void 0, function* () { return arguments_10; }); });
};
const a4 = (...args_2) => __awaiter(this, [...args_2], void 0, function* (x = z) { return () => __awaiter(this, void 0, void 0, function* () { return () => __awaiter(this, void 0, void 0, function* () { return arguments_10; }); }); });
const a5 = (...args_3) => __awaiter(this, [...args_3], void 0, function* (x = z, ...args) { });
const a6 = (...args_4) => __awaiter(this, [...args_4], void 0, function* (x = z, ...args) { return () => __awaiter(this, void 0, void 0, function* () { return arguments_10; }); });
const a7 = (...args_5) => __awaiter(this, [...args_5], void 0, function* (x = z, ...args) { return () => __awaiter(this, void 0, void 0, function* () { return () => __awaiter(this, void 0, void 0, function* () { return arguments_10; }); }); });
const a8 = () => __awaiter(this, void 0, void 0, function* () { return (...args_6) => __awaiter(this, [...args_6], void 0, function* (x = z) { return arguments_10; }); });
const a9 = () => __awaiter(this, void 0, void 0, function* () { return (...args_7) => __awaiter(this, [...args_7], void 0, function* (x = z) { return () => __awaiter(this, void 0, void 0, function* () { return arguments_10; }); }); });
const a10 = (...args_8) => __awaiter(this, [...args_8], void 0, function* (x = z) { return () => __awaiter(this, void 0, void 0, function* () { return function () {
const a4 = (...args_1) => __awaiter(this, [...args_1], void 0, function* (x = z) { return () => __awaiter(this, void 0, void 0, function* () { return () => __awaiter(this, void 0, void 0, function* () { return arguments_10; }); }); });
const a5 = (...args_1) => __awaiter(this, [...args_1], void 0, function* (x = z, ...args) { });
const a6 = (...args_1) => __awaiter(this, [...args_1], void 0, function* (x = z, ...args) { return () => __awaiter(this, void 0, void 0, function* () { return arguments_10; }); });
const a7 = (...args_1) => __awaiter(this, [...args_1], void 0, function* (x = z, ...args) { return () => __awaiter(this, void 0, void 0, function* () { return () => __awaiter(this, void 0, void 0, function* () { return arguments_10; }); }); });
const a8 = () => __awaiter(this, void 0, void 0, function* () { return (...args_1) => __awaiter(this, [...args_1], void 0, function* (x = z) { return arguments_10; }); });
const a9 = () => __awaiter(this, void 0, void 0, function* () { return (...args_1) => __awaiter(this, [...args_1], void 0, function* (x = z) { return () => __awaiter(this, void 0, void 0, function* () { return arguments_10; }); }); });
const a10 = (...args_1) => __awaiter(this, [...args_1], void 0, function* (x = z) { return () => __awaiter(this, void 0, void 0, function* () { return function () {
var arguments_11 = arguments;
return __awaiter(this, void 0, void 0, function* () { return () => __awaiter(this, void 0, void 0, function* () { return arguments_11; }); });
}; }); });
Expand Down
6 changes: 3 additions & 3 deletions tests/baselines/reference/autoAccessor5(target=es2022).js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class C1 {
static set ["z"](value) { C1.#_d_accessor_storage = value; }
}
class C2 {
#_e_accessor_storage = 1;
get [_a = f()]() { return this.#_e_accessor_storage; }
set [_a](value) { this.#_e_accessor_storage = value; }
#_a_accessor_storage = 1;
get [_a = f()]() { return this.#_a_accessor_storage; }
set [_a](value) { this.#_a_accessor_storage = value; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,10 @@ let C = (() => {
set x(value) { }
/*13*/
y = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _y_initializers, 1));
#z_accessor_storage = (__runInitializers(this, _y_extraInitializers), __runInitializers(this, _z_initializers, 1));
#z_1_accessor_storage = (__runInitializers(this, _y_extraInitializers), __runInitializers(this, _z_initializers, 1));
/*16*/
get z() { return this.#z_accessor_storage; }
set z(value) { this.#z_accessor_storage = value; }
get z() { return this.#z_1_accessor_storage; }
set z(value) { this.#z_1_accessor_storage = value; }
static {
/*28*/
_C_y = { value: (__runInitializers(_classThis, _staticExtraInitializers), __runInitializers(_classThis, _static_private_y_initializers, 1)) };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,10 @@ let C = (() => {
set x(value) { }
/*13*/
y = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _y_initializers, 1));
#z_accessor_storage = (__runInitializers(this, _y_extraInitializers), __runInitializers(this, _z_initializers, 1));
#z_1_accessor_storage = (__runInitializers(this, _y_extraInitializers), __runInitializers(this, _z_initializers, 1));
/*16*/
get z() { return this.#z_accessor_storage; }
set z(value) { this.#z_accessor_storage = value; }
get z() { return this.#z_1_accessor_storage; }
set z(value) { this.#z_1_accessor_storage = value; }
static {
/*28*/
_C_y = { value: (__runInitializers(_classThis, _staticExtraInitializers), __runInitializers(_classThis, _static_private_y_initializers, 1)) };
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts
5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6 > ^
7 > ^^^
8 > ^^^^^^^^^^^^^->
8 > ^^^^^^^^^^^^^^^->
1->
>
> @dec
Expand Down Expand Up @@ -742,52 +742,52 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts
6 >Emitted(117, 109) Source(20, 10) + SourceIndex(0)
7 >Emitted(117, 112) Source(20, 11) + SourceIndex(0)
---
>>> #z_accessor_storage = (__runInitializers(this, _y_extraInitializers), __runInitializers(this, _z_initializers, 1));
>>> #z_1_accessor_storage = (__runInitializers(this, _y_extraInitializers), __runInitializers(this, _z_initializers, 1));
1->^^^^^^^^
2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3 > ^
4 > ^^^
2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3 > ^
4 > ^^^
1->
>
> @dec
> @dec
>
2 > accessor z =
3 > 1
4 > ;
3 > 1
4 > ;
1->Emitted(118, 9) Source(24, 5) + SourceIndex(0)
2 >Emitted(118, 120) Source(24, 18) + SourceIndex(0)
3 >Emitted(118, 121) Source(24, 19) + SourceIndex(0)
4 >Emitted(118, 124) Source(24, 20) + SourceIndex(0)
2 >Emitted(118, 122) Source(24, 18) + SourceIndex(0)
3 >Emitted(118, 123) Source(24, 19) + SourceIndex(0)
4 >Emitted(118, 126) Source(24, 20) + SourceIndex(0)
---
>>> get z() { return this.#z_accessor_storage; }
>>> get z() { return this.#z_1_accessor_storage; }
1 >^^^^^^^^
2 > ^^^^
3 > ^
4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5 > ^^^^^^^->
4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5 > ^^^^^^^->
1 >
2 > accessor
3 > z
4 > = 1;
1 >Emitted(119, 9) Source(24, 5) + SourceIndex(0)
2 >Emitted(119, 13) Source(24, 14) + SourceIndex(0)
3 >Emitted(119, 14) Source(24, 15) + SourceIndex(0)
4 >Emitted(119, 53) Source(24, 20) + SourceIndex(0)
4 >Emitted(119, 55) Source(24, 20) + SourceIndex(0)
---
>>> set z(value) { this.#z_accessor_storage = value; }
>>> set z(value) { this.#z_1_accessor_storage = value; }
1->^^^^^^^^
2 > ^^^^
3 > ^
4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1->
2 > accessor
3 > z
4 > = 1;
1->Emitted(120, 9) Source(24, 5) + SourceIndex(0)
2 >Emitted(120, 13) Source(24, 14) + SourceIndex(0)
3 >Emitted(120, 14) Source(24, 15) + SourceIndex(0)
4 >Emitted(120, 59) Source(24, 20) + SourceIndex(0)
4 >Emitted(120, 61) Source(24, 20) + SourceIndex(0)
---
>>> static {
>>> _C_y = { value: (__runInitializers(_classThis, _staticExtraInitializers), __runInitializers(_classThis, _static_private_y_initializers, 1)) };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ class C {
set x(value) { }
/*14*/
y = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _y_initializers, 1));
#z_accessor_storage = (__runInitializers(this, _y_extraInitializers), __runInitializers(this, _z_initializers, 1));
#z_1_accessor_storage = (__runInitializers(this, _y_extraInitializers), __runInitializers(this, _z_initializers, 1));
/*17*/
get z() { return this.#z_accessor_storage; }
set z(value) { this.#z_accessor_storage = value; }
get z() { return this.#z_1_accessor_storage; }
set z(value) { this.#z_1_accessor_storage = value; }
static {
/*29*/
_C_y = { value: (__runInitializers(_classThis, _staticExtraInitializers), __runInitializers(_classThis, _static_private_y_initializers, 1)) };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ class A {
var _c;
this.otherClass = _b;
let y;
({ x: ({ set value(_b) { __classPrivateFieldSet(_b, _b, _b, "f", _A_field); } }).value, y } = this.testObject());
([({ set value(_b) { __classPrivateFieldSet(_b, _b, _b, "f", _A_field); } }).value, y] = this.testArray());
({ a: ({ set value(_b) { __classPrivateFieldSet(_b, _b, _b, "f", _A_field); } }).value, b: [({ set value(_b) { __classPrivateFieldSet(_b, _b, _b, "f", _A_field); } }).value] } = { a: 1, b: [2] });
[({ set value(_b) { __classPrivateFieldSet(_b, _b, _b, "f", _A_field); } }).value, [({ set value(_b) { __classPrivateFieldSet(_b, _b, _b, "f", _A_field); } }).value]] = [1, [2]];
({ a: ({ set value(_b) { __classPrivateFieldSet(_b, _b, _b, "f", _A_field); } }).value = 1, b: [({ set value(_b) { __classPrivateFieldSet(_b, _b, _b, "f", _A_field); } }).value = 1] } = { b: [] });
[({ set value(_b) { __classPrivateFieldSet(_b, _b, _b, "f", _A_field); } }).value = 2] = [];
_c = this.otherClass, [({ set value(_b) { __classPrivateFieldSet(_c, _b, _b, "f", _A_field); } }).value = 2] = [];
({ x: ({ set value(_d) { __classPrivateFieldSet(_b, _b, _d, "f", _A_field); } }).value, y } = this.testObject());
([({ set value(_d) { __classPrivateFieldSet(_b, _b, _d, "f", _A_field); } }).value, y] = this.testArray());
({ a: ({ set value(_d) { __classPrivateFieldSet(_b, _b, _d, "f", _A_field); } }).value, b: [({ set value(_d) { __classPrivateFieldSet(_b, _b, _d, "f", _A_field); } }).value] } = { a: 1, b: [2] });
[({ set value(_d) { __classPrivateFieldSet(_b, _b, _d, "f", _A_field); } }).value, [({ set value(_d) { __classPrivateFieldSet(_b, _b, _d, "f", _A_field); } }).value]] = [1, [2]];
({ a: ({ set value(_d) { __classPrivateFieldSet(_b, _b, _d, "f", _A_field); } }).value = 1, b: [({ set value(_d) { __classPrivateFieldSet(_b, _b, _d, "f", _A_field); } }).value = 1] } = { b: [] });
[({ set value(_d) { __classPrivateFieldSet(_b, _b, _d, "f", _A_field); } }).value = 2] = [];
_c = this.otherClass, [({ set value(_d) { __classPrivateFieldSet(_c, _b, _d, "f", _A_field); } }).value = 2] = [];
}
static test(_a) {
[({ set value(_c) { __classPrivateFieldSet(_a, _b, _c, "f", _A_field); } }).value] = [2];
Expand Down