From dba78a0031b97a4c152b506ae2072438cdba92b2 Mon Sep 17 00:00:00 2001 From: Yunfei He Date: Wed, 17 May 2023 21:10:27 +0800 Subject: [PATCH] fix(es/compat): Mark reserved function names private (#7298) --- .../issues-1xxx/1681/es3/output/input.js | 2 +- .../issues-1xxx/1681/es5/output/input.js | 2 +- .../issues-1xxx/1742/case1/output/index.js | 2 +- .../issues-2xxx/2468/1/output/index.js | 2 +- .../issues-5xxx/5068/1/output/index.js | 2 +- .../fixture/issues-5xxx/5556/output/index.js | 2 +- .../fixture/issues-7xxx/7253/input/.swcrc | 9 ++++ .../fixture/issues-7xxx/7253/input/input.js | 5 ++ .../fixture/issues-7xxx/7253/output/input.js | 5 ++ .../tsc-references/asOperator3.1.normal.js | 2 +- ...xportDoubleAssignmentInClosure.1.normal.js | 2 +- ...teStringsTypeArgumentInference.1.normal.js | 54 +++++++++---------- ...ringsWithIncompatibleTypedTags.1.normal.js | 22 ++++---- ...StringsWithOverloadResolution1.1.normal.js | 10 ++-- ...StringsWithOverloadResolution2.1.normal.js | 2 +- ...StringsWithOverloadResolution3.1.normal.js | 42 +++++++-------- ...plateStringsWithTagsTypedAsAny.1.normal.js | 22 ++++---- ...edTemplateStringsWithTypedTags.1.normal.js | 18 +++---- .../tests/es2015_function_name.rs | 2 +- .../src/es2015/function_name.rs | 4 +- 20 files changed, 115 insertions(+), 96 deletions(-) create mode 100644 crates/swc/tests/fixture/issues-7xxx/7253/input/.swcrc create mode 100644 crates/swc/tests/fixture/issues-7xxx/7253/input/input.js create mode 100644 crates/swc/tests/fixture/issues-7xxx/7253/output/input.js diff --git a/crates/swc/tests/fixture/issues-1xxx/1681/es3/output/input.js b/crates/swc/tests/fixture/issues-1xxx/1681/es3/output/input.js index 5270266cfb5..2fe4cb3a0a2 100644 --- a/crates/swc/tests/fixture/issues-1xxx/1681/es3/output/input.js +++ b/crates/swc/tests/fixture/issues-1xxx/1681/es3/output/input.js @@ -14,7 +14,7 @@ function _templateObject1() { ], [ "a\\nb\\nc\\n" ]); - _templateObject1 = function _templateObject1() { + _templateObject1 = function _templateObject() { return data; }; return data; diff --git a/crates/swc/tests/fixture/issues-1xxx/1681/es5/output/input.js b/crates/swc/tests/fixture/issues-1xxx/1681/es5/output/input.js index 5270266cfb5..2fe4cb3a0a2 100644 --- a/crates/swc/tests/fixture/issues-1xxx/1681/es5/output/input.js +++ b/crates/swc/tests/fixture/issues-1xxx/1681/es5/output/input.js @@ -14,7 +14,7 @@ function _templateObject1() { ], [ "a\\nb\\nc\\n" ]); - _templateObject1 = function _templateObject1() { + _templateObject1 = function _templateObject() { return data; }; return data; diff --git a/crates/swc/tests/fixture/issues-1xxx/1742/case1/output/index.js b/crates/swc/tests/fixture/issues-1xxx/1742/case1/output/index.js index a816b9dbc18..b31336bcae2 100644 --- a/crates/swc/tests/fixture/issues-1xxx/1742/case1/output/index.js +++ b/crates/swc/tests/fixture/issues-1xxx/1742/case1/output/index.js @@ -17,7 +17,7 @@ function _templateObject1() { var data = _tagged_template_literal([ "tagged template" ]); - _templateObject1 = function _templateObject1() { + _templateObject1 = function _templateObject() { return data; }; return data; diff --git a/crates/swc/tests/fixture/issues-2xxx/2468/1/output/index.js b/crates/swc/tests/fixture/issues-2xxx/2468/1/output/index.js index 4d7a9068aae..80c48321cd4 100644 --- a/crates/swc/tests/fixture/issues-2xxx/2468/1/output/index.js +++ b/crates/swc/tests/fixture/issues-2xxx/2468/1/output/index.js @@ -12,7 +12,7 @@ function _templateObject1() { var data = _tagged_template_literal([ "2" ]); - _templateObject1 = function _templateObject1() { + _templateObject1 = function _templateObject() { return data; }; return data; diff --git a/crates/swc/tests/fixture/issues-5xxx/5068/1/output/index.js b/crates/swc/tests/fixture/issues-5xxx/5068/1/output/index.js index 47e05eca3d0..df157fafe3a 100644 --- a/crates/swc/tests/fixture/issues-5xxx/5068/1/output/index.js +++ b/crates/swc/tests/fixture/issues-5xxx/5068/1/output/index.js @@ -12,7 +12,7 @@ function _templateObject1() { var data = _tagged_template_literal([ "\n position: absolute;\n" ]); - _templateObject1 = function _templateObject1() { + _templateObject1 = function _templateObject() { return data; }; return data; diff --git a/crates/swc/tests/fixture/issues-5xxx/5556/output/index.js b/crates/swc/tests/fixture/issues-5xxx/5556/output/index.js index a2ac04320d6..2aa981bd348 100644 --- a/crates/swc/tests/fixture/issues-5xxx/5556/output/index.js +++ b/crates/swc/tests/fixture/issues-5xxx/5556/output/index.js @@ -1,7 +1,7 @@ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator"; var app; var ctx; -x = function x() { +x = function x1() { var y = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function(app) { return { schedule: { diff --git a/crates/swc/tests/fixture/issues-7xxx/7253/input/.swcrc b/crates/swc/tests/fixture/issues-7xxx/7253/input/.swcrc new file mode 100644 index 00000000000..dc0b8f887b6 --- /dev/null +++ b/crates/swc/tests/fixture/issues-7xxx/7253/input/.swcrc @@ -0,0 +1,9 @@ +{ + "jsc": { + "parser": { + "syntax": "ecmascript", + "jsx": false + }, + "target": "es5" + } +} \ No newline at end of file diff --git a/crates/swc/tests/fixture/issues-7xxx/7253/input/input.js b/crates/swc/tests/fixture/issues-7xxx/7253/input/input.js new file mode 100644 index 00000000000..4cb0f47fafc --- /dev/null +++ b/crates/swc/tests/fixture/issues-7xxx/7253/input/input.js @@ -0,0 +1,5 @@ +var bmRnd; +function a() { + bmRnd = function () {}; +} +eval(''); \ No newline at end of file diff --git a/crates/swc/tests/fixture/issues-7xxx/7253/output/input.js b/crates/swc/tests/fixture/issues-7xxx/7253/output/input.js new file mode 100644 index 00000000000..afc3fb69ce7 --- /dev/null +++ b/crates/swc/tests/fixture/issues-7xxx/7253/output/input.js @@ -0,0 +1,5 @@ +var bmRnd; +function a() { + bmRnd = function bmRnd1() {}; +} +eval(""); diff --git a/crates/swc/tests/tsc-references/asOperator3.1.normal.js b/crates/swc/tests/tsc-references/asOperator3.1.normal.js index 0325a994f80..470426f8535 100644 --- a/crates/swc/tests/tsc-references/asOperator3.1.normal.js +++ b/crates/swc/tests/tsc-references/asOperator3.1.normal.js @@ -14,7 +14,7 @@ function _templateObject1() { var data = _tagged_template_literal([ "Hello" ]); - _templateObject1 = function _templateObject1() { + _templateObject1 = function _templateObject() { return data; }; return data; diff --git a/crates/swc/tests/tsc-references/jsDeclarationsExportDoubleAssignmentInClosure.1.normal.js b/crates/swc/tests/tsc-references/jsDeclarationsExportDoubleAssignmentInClosure.1.normal.js index dd99c4cd428..859050b8453 100644 --- a/crates/swc/tests/tsc-references/jsDeclarationsExportDoubleAssignmentInClosure.1.normal.js +++ b/crates/swc/tests/tsc-references/jsDeclarationsExportDoubleAssignmentInClosure.1.normal.js @@ -1,7 +1,7 @@ //// [index.js] // @ts-nocheck function foo() { - module.exports = exports = function exports(o) { + module.exports = exports = function exports1(o) { return o == null ? create(base) : defineProperties(Object(o), descriptors); }; var m = function m() { diff --git a/crates/swc/tests/tsc-references/taggedTemplateStringsTypeArgumentInference.1.normal.js b/crates/swc/tests/tsc-references/taggedTemplateStringsTypeArgumentInference.1.normal.js index d791c0aa7d7..e5a60b374f5 100644 --- a/crates/swc/tests/tsc-references/taggedTemplateStringsTypeArgumentInference.1.normal.js +++ b/crates/swc/tests/tsc-references/taggedTemplateStringsTypeArgumentInference.1.normal.js @@ -14,7 +14,7 @@ function _templateObject1() { var data = _tagged_template_literal([ "" ]); - _templateObject1 = function _templateObject1() { + _templateObject1 = function _templateObject() { return data; }; return data; @@ -24,7 +24,7 @@ function _templateObject2() { "", "" ]); - _templateObject2 = function _templateObject2() { + _templateObject2 = function _templateObject() { return data; }; return data; @@ -34,7 +34,7 @@ function _templateObject3() { "", "" ]); - _templateObject3 = function _templateObject3() { + _templateObject3 = function _templateObject() { return data; }; return data; @@ -44,7 +44,7 @@ function _templateObject4() { "", "" ]); - _templateObject4 = function _templateObject4() { + _templateObject4 = function _templateObject() { return data; }; return data; @@ -54,7 +54,7 @@ function _templateObject5() { "", "" ]); - _templateObject5 = function _templateObject5() { + _templateObject5 = function _templateObject() { return data; }; return data; @@ -64,7 +64,7 @@ function _templateObject6() { "", "" ]); - _templateObject6 = function _templateObject6() { + _templateObject6 = function _templateObject() { return data; }; return data; @@ -74,7 +74,7 @@ function _templateObject7() { "", "" ]); - _templateObject7 = function _templateObject7() { + _templateObject7 = function _templateObject() { return data; }; return data; @@ -84,7 +84,7 @@ function _templateObject8() { "", "" ]); - _templateObject8 = function _templateObject8() { + _templateObject8 = function _templateObject() { return data; }; return data; @@ -95,7 +95,7 @@ function _templateObject9() { "", "" ]); - _templateObject9 = function _templateObject9() { + _templateObject9 = function _templateObject() { return data; }; return data; @@ -106,7 +106,7 @@ function _templateObject10() { "", "" ]); - _templateObject10 = function _templateObject10() { + _templateObject10 = function _templateObject() { return data; }; return data; @@ -117,7 +117,7 @@ function _templateObject11() { "", "" ]); - _templateObject11 = function _templateObject11() { + _templateObject11 = function _templateObject() { return data; }; return data; @@ -128,7 +128,7 @@ function _templateObject12() { " ", "" ]); - _templateObject12 = function _templateObject12() { + _templateObject12 = function _templateObject() { return data; }; return data; @@ -139,7 +139,7 @@ function _templateObject13() { "", "" ]); - _templateObject13 = function _templateObject13() { + _templateObject13 = function _templateObject() { return data; }; return data; @@ -150,7 +150,7 @@ function _templateObject14() { "", "" ]); - _templateObject14 = function _templateObject14() { + _templateObject14 = function _templateObject() { return data; }; return data; @@ -162,7 +162,7 @@ function _templateObject15() { "", "" ]); - _templateObject15 = function _templateObject15() { + _templateObject15 = function _templateObject() { return data; }; return data; @@ -174,7 +174,7 @@ function _templateObject16() { "", "" ]); - _templateObject16 = function _templateObject16() { + _templateObject16 = function _templateObject() { return data; }; return data; @@ -186,7 +186,7 @@ function _templateObject17() { "", "" ]); - _templateObject17 = function _templateObject17() { + _templateObject17 = function _templateObject() { return data; }; return data; @@ -198,7 +198,7 @@ function _templateObject18() { "", "" ]); - _templateObject18 = function _templateObject18() { + _templateObject18 = function _templateObject() { return data; }; return data; @@ -210,7 +210,7 @@ function _templateObject19() { "", "" ]); - _templateObject19 = function _templateObject19() { + _templateObject19 = function _templateObject() { return data; }; return data; @@ -222,7 +222,7 @@ function _templateObject20() { "", "" ]); - _templateObject20 = function _templateObject20() { + _templateObject20 = function _templateObject() { return data; }; return data; @@ -232,7 +232,7 @@ function _templateObject21() { "", "" ]); - _templateObject21 = function _templateObject21() { + _templateObject21 = function _templateObject() { return data; }; return data; @@ -244,7 +244,7 @@ function _templateObject22() { "", "" ]); - _templateObject22 = function _templateObject22() { + _templateObject22 = function _templateObject() { return data; }; return data; @@ -256,7 +256,7 @@ function _templateObject23() { "", "" ]); - _templateObject23 = function _templateObject23() { + _templateObject23 = function _templateObject() { return data; }; return data; @@ -268,7 +268,7 @@ function _templateObject24() { "", "" ]); - _templateObject24 = function _templateObject24() { + _templateObject24 = function _templateObject() { return data; }; return data; @@ -280,7 +280,7 @@ function _templateObject25() { "", "" ]); - _templateObject25 = function _templateObject25() { + _templateObject25 = function _templateObject() { return data; }; return data; @@ -292,7 +292,7 @@ function _templateObject26() { "", "" ]); - _templateObject26 = function _templateObject26() { + _templateObject26 = function _templateObject() { return data; }; return data; @@ -304,7 +304,7 @@ function _templateObject27() { "", "" ]); - _templateObject27 = function _templateObject27() { + _templateObject27 = function _templateObject() { return data; }; return data; diff --git a/crates/swc/tests/tsc-references/taggedTemplateStringsWithIncompatibleTypedTags.1.normal.js b/crates/swc/tests/tsc-references/taggedTemplateStringsWithIncompatibleTypedTags.1.normal.js index 99ff38506e7..2cc48a82799 100644 --- a/crates/swc/tests/tsc-references/taggedTemplateStringsWithIncompatibleTypedTags.1.normal.js +++ b/crates/swc/tests/tsc-references/taggedTemplateStringsWithIncompatibleTypedTags.1.normal.js @@ -15,7 +15,7 @@ function _templateObject1() { "def", "ghi" ]); - _templateObject1 = function _templateObject1() { + _templateObject1 = function _templateObject() { return data; }; return data; @@ -24,7 +24,7 @@ function _templateObject2() { var data = _tagged_template_literal([ "abc" ]); - _templateObject2 = function _templateObject2() { + _templateObject2 = function _templateObject() { return data; }; return data; @@ -35,7 +35,7 @@ function _templateObject3() { "def", "ghi" ]); - _templateObject3 = function _templateObject3() { + _templateObject3 = function _templateObject() { return data; }; return data; @@ -44,7 +44,7 @@ function _templateObject4() { var data = _tagged_template_literal([ "abc" ]); - _templateObject4 = function _templateObject4() { + _templateObject4 = function _templateObject() { return data; }; return data; @@ -55,7 +55,7 @@ function _templateObject5() { "def", "ghi" ]); - _templateObject5 = function _templateObject5() { + _templateObject5 = function _templateObject() { return data; }; return data; @@ -64,7 +64,7 @@ function _templateObject6() { var data = _tagged_template_literal([ "abc" ]); - _templateObject6 = function _templateObject6() { + _templateObject6 = function _templateObject() { return data; }; return data; @@ -75,7 +75,7 @@ function _templateObject7() { "def", "ghi" ]); - _templateObject7 = function _templateObject7() { + _templateObject7 = function _templateObject() { return data; }; return data; @@ -86,7 +86,7 @@ function _templateObject8() { "def", "ghi" ]); - _templateObject8 = function _templateObject8() { + _templateObject8 = function _templateObject() { return data; }; return data; @@ -97,7 +97,7 @@ function _templateObject9() { "def", "ghi" ]); - _templateObject9 = function _templateObject9() { + _templateObject9 = function _templateObject() { return data; }; return data; @@ -108,7 +108,7 @@ function _templateObject10() { "def", "ghi" ]); - _templateObject10 = function _templateObject10() { + _templateObject10 = function _templateObject() { return data; }; return data; @@ -119,7 +119,7 @@ function _templateObject11() { "def", "ghi" ]); - _templateObject11 = function _templateObject11() { + _templateObject11 = function _templateObject() { return data; }; return data; diff --git a/crates/swc/tests/tsc-references/taggedTemplateStringsWithOverloadResolution1.1.normal.js b/crates/swc/tests/tsc-references/taggedTemplateStringsWithOverloadResolution1.1.normal.js index fd98564e7b5..eeb96c032bf 100644 --- a/crates/swc/tests/tsc-references/taggedTemplateStringsWithOverloadResolution1.1.normal.js +++ b/crates/swc/tests/tsc-references/taggedTemplateStringsWithOverloadResolution1.1.normal.js @@ -14,7 +14,7 @@ function _templateObject1() { "", "" ]); - _templateObject1 = function _templateObject1() { + _templateObject1 = function _templateObject() { return data; }; return data; @@ -25,7 +25,7 @@ function _templateObject2() { "", "" ]); - _templateObject2 = function _templateObject2() { + _templateObject2 = function _templateObject() { return data; }; return data; @@ -36,7 +36,7 @@ function _templateObject3() { "", "" ]); - _templateObject3 = function _templateObject3() { + _templateObject3 = function _templateObject() { return data; }; return data; @@ -47,7 +47,7 @@ function _templateObject4() { "", "" ]); - _templateObject4 = function _templateObject4() { + _templateObject4 = function _templateObject() { return data; }; return data; @@ -59,7 +59,7 @@ function _templateObject5() { "", "" ]); - _templateObject5 = function _templateObject5() { + _templateObject5 = function _templateObject() { return data; }; return data; diff --git a/crates/swc/tests/tsc-references/taggedTemplateStringsWithOverloadResolution2.1.normal.js b/crates/swc/tests/tsc-references/taggedTemplateStringsWithOverloadResolution2.1.normal.js index 264ff2c557b..b6cac5c0b6f 100644 --- a/crates/swc/tests/tsc-references/taggedTemplateStringsWithOverloadResolution2.1.normal.js +++ b/crates/swc/tests/tsc-references/taggedTemplateStringsWithOverloadResolution2.1.normal.js @@ -15,7 +15,7 @@ function _templateObject1() { "", "" ]); - _templateObject1 = function _templateObject1() { + _templateObject1 = function _templateObject() { return data; }; return data; diff --git a/crates/swc/tests/tsc-references/taggedTemplateStringsWithOverloadResolution3.1.normal.js b/crates/swc/tests/tsc-references/taggedTemplateStringsWithOverloadResolution3.1.normal.js index 71e83a9cbed..f91899c5aa4 100644 --- a/crates/swc/tests/tsc-references/taggedTemplateStringsWithOverloadResolution3.1.normal.js +++ b/crates/swc/tests/tsc-references/taggedTemplateStringsWithOverloadResolution3.1.normal.js @@ -16,7 +16,7 @@ function _templateObject1() { "", "" ]); - _templateObject1 = function _templateObject1() { + _templateObject1 = function _templateObject() { return data; }; return data; @@ -27,7 +27,7 @@ function _templateObject2() { "", "" ]); - _templateObject2 = function _templateObject2() { + _templateObject2 = function _templateObject() { return data; }; return data; @@ -38,7 +38,7 @@ function _templateObject3() { "", "" ]); - _templateObject3 = function _templateObject3() { + _templateObject3 = function _templateObject() { return data; }; return data; @@ -49,7 +49,7 @@ function _templateObject4() { "", "" ]); - _templateObject4 = function _templateObject4() { + _templateObject4 = function _templateObject() { return data; }; return data; @@ -60,7 +60,7 @@ function _templateObject5() { "", "" ]); - _templateObject5 = function _templateObject5() { + _templateObject5 = function _templateObject() { return data; }; return data; @@ -70,7 +70,7 @@ function _templateObject6() { "", "" ]); - _templateObject6 = function _templateObject6() { + _templateObject6 = function _templateObject() { return data; }; return data; @@ -82,7 +82,7 @@ function _templateObject7() { "", "" ]); - _templateObject7 = function _templateObject7() { + _templateObject7 = function _templateObject() { return data; }; return data; @@ -94,7 +94,7 @@ function _templateObject8() { "", "" ]); - _templateObject8 = function _templateObject8() { + _templateObject8 = function _templateObject() { return data; }; return data; @@ -104,7 +104,7 @@ function _templateObject9() { "", "" ]); - _templateObject9 = function _templateObject9() { + _templateObject9 = function _templateObject() { return data; }; return data; @@ -116,7 +116,7 @@ function _templateObject10() { "", "" ]); - _templateObject10 = function _templateObject10() { + _templateObject10 = function _templateObject() { return data; }; return data; @@ -128,7 +128,7 @@ function _templateObject11() { "", "" ]); - _templateObject11 = function _templateObject11() { + _templateObject11 = function _templateObject() { return data; }; return data; @@ -137,7 +137,7 @@ function _templateObject12() { var data = _tagged_template_literal([ "" ]); - _templateObject12 = function _templateObject12() { + _templateObject12 = function _templateObject() { return data; }; return data; @@ -148,7 +148,7 @@ function _templateObject13() { "", "" ]); - _templateObject13 = function _templateObject13() { + _templateObject13 = function _templateObject() { return data; }; return data; @@ -159,7 +159,7 @@ function _templateObject14() { "", "" ]); - _templateObject14 = function _templateObject14() { + _templateObject14 = function _templateObject() { return data; }; return data; @@ -170,7 +170,7 @@ function _templateObject15() { "", "" ]); - _templateObject15 = function _templateObject15() { + _templateObject15 = function _templateObject() { return data; }; return data; @@ -181,7 +181,7 @@ function _templateObject16() { "", "" ]); - _templateObject16 = function _templateObject16() { + _templateObject16 = function _templateObject() { return data; }; return data; @@ -192,7 +192,7 @@ function _templateObject17() { "", "" ]); - _templateObject17 = function _templateObject17() { + _templateObject17 = function _templateObject() { return data; }; return data; @@ -203,7 +203,7 @@ function _templateObject18() { "", "" ]); - _templateObject18 = function _templateObject18() { + _templateObject18 = function _templateObject() { return data; }; return data; @@ -214,7 +214,7 @@ function _templateObject19() { "", "" ]); - _templateObject19 = function _templateObject19() { + _templateObject19 = function _templateObject() { return data; }; return data; @@ -224,7 +224,7 @@ function _templateObject20() { "", "" ]); - _templateObject20 = function _templateObject20() { + _templateObject20 = function _templateObject() { return data; }; return data; @@ -234,7 +234,7 @@ function _templateObject21() { "", "" ]); - _templateObject21 = function _templateObject21() { + _templateObject21 = function _templateObject() { return data; }; return data; diff --git a/crates/swc/tests/tsc-references/taggedTemplateStringsWithTagsTypedAsAny.1.normal.js b/crates/swc/tests/tsc-references/taggedTemplateStringsWithTagsTypedAsAny.1.normal.js index dbc9628e7e5..c424c3b2ad1 100644 --- a/crates/swc/tests/tsc-references/taggedTemplateStringsWithTagsTypedAsAny.1.normal.js +++ b/crates/swc/tests/tsc-references/taggedTemplateStringsWithTagsTypedAsAny.1.normal.js @@ -15,7 +15,7 @@ function _templateObject1() { "def", "ghi" ]); - _templateObject1 = function _templateObject1() { + _templateObject1 = function _templateObject() { return data; }; return data; @@ -24,7 +24,7 @@ function _templateObject2() { var data = _tagged_template_literal([ "abc" ]); - _templateObject2 = function _templateObject2() { + _templateObject2 = function _templateObject() { return data; }; return data; @@ -35,7 +35,7 @@ function _templateObject3() { "def", "ghi" ]); - _templateObject3 = function _templateObject3() { + _templateObject3 = function _templateObject() { return data; }; return data; @@ -44,7 +44,7 @@ function _templateObject4() { var data = _tagged_template_literal([ "abc" ]); - _templateObject4 = function _templateObject4() { + _templateObject4 = function _templateObject() { return data; }; return data; @@ -55,7 +55,7 @@ function _templateObject5() { "def", "ghi" ]); - _templateObject5 = function _templateObject5() { + _templateObject5 = function _templateObject() { return data; }; return data; @@ -64,7 +64,7 @@ function _templateObject6() { var data = _tagged_template_literal([ "abc" ]); - _templateObject6 = function _templateObject6() { + _templateObject6 = function _templateObject() { return data; }; return data; @@ -75,7 +75,7 @@ function _templateObject7() { "def", "ghi" ]); - _templateObject7 = function _templateObject7() { + _templateObject7 = function _templateObject() { return data; }; return data; @@ -84,7 +84,7 @@ function _templateObject8() { var data = _tagged_template_literal([ "abc" ]); - _templateObject8 = function _templateObject8() { + _templateObject8 = function _templateObject() { return data; }; return data; @@ -95,7 +95,7 @@ function _templateObject9() { "def", "ghi" ]); - _templateObject9 = function _templateObject9() { + _templateObject9 = function _templateObject() { return data; }; return data; @@ -106,7 +106,7 @@ function _templateObject10() { "def", "ghi" ]); - _templateObject10 = function _templateObject10() { + _templateObject10 = function _templateObject() { return data; }; return data; @@ -117,7 +117,7 @@ function _templateObject11() { "def", "ghi" ]); - _templateObject11 = function _templateObject11() { + _templateObject11 = function _templateObject() { return data; }; return data; diff --git a/crates/swc/tests/tsc-references/taggedTemplateStringsWithTypedTags.1.normal.js b/crates/swc/tests/tsc-references/taggedTemplateStringsWithTypedTags.1.normal.js index fba7475b3cb..f27c84c88f8 100644 --- a/crates/swc/tests/tsc-references/taggedTemplateStringsWithTypedTags.1.normal.js +++ b/crates/swc/tests/tsc-references/taggedTemplateStringsWithTypedTags.1.normal.js @@ -15,7 +15,7 @@ function _templateObject1() { "def", "ghi" ]); - _templateObject1 = function _templateObject1() { + _templateObject1 = function _templateObject() { return data; }; return data; @@ -24,7 +24,7 @@ function _templateObject2() { var data = _tagged_template_literal([ "abc" ]); - _templateObject2 = function _templateObject2() { + _templateObject2 = function _templateObject() { return data; }; return data; @@ -35,7 +35,7 @@ function _templateObject3() { "def", "ghi" ]); - _templateObject3 = function _templateObject3() { + _templateObject3 = function _templateObject() { return data; }; return data; @@ -44,7 +44,7 @@ function _templateObject4() { var data = _tagged_template_literal([ "abc" ]); - _templateObject4 = function _templateObject4() { + _templateObject4 = function _templateObject() { return data; }; return data; @@ -55,7 +55,7 @@ function _templateObject5() { "def", "ghi" ]); - _templateObject5 = function _templateObject5() { + _templateObject5 = function _templateObject() { return data; }; return data; @@ -64,7 +64,7 @@ function _templateObject6() { var data = _tagged_template_literal([ "abc" ]); - _templateObject6 = function _templateObject6() { + _templateObject6 = function _templateObject() { return data; }; return data; @@ -75,7 +75,7 @@ function _templateObject7() { "def", "ghi" ]); - _templateObject7 = function _templateObject7() { + _templateObject7 = function _templateObject() { return data; }; return data; @@ -86,7 +86,7 @@ function _templateObject8() { "def", "ghi" ]); - _templateObject8 = function _templateObject8() { + _templateObject8 = function _templateObject() { return data; }; return data; @@ -97,7 +97,7 @@ function _templateObject9() { "def", "ghi" ]); - _templateObject9 = function _templateObject9() { + _templateObject9 = function _templateObject() { return data; }; return data; diff --git a/crates/swc_ecma_transforms/tests/es2015_function_name.rs b/crates/swc_ecma_transforms/tests/es2015_function_name.rs index e3905430402..4196feca8d8 100644 --- a/crates/swc_ecma_transforms/tests/es2015_function_name.rs +++ b/crates/swc_ecma_transforms/tests/es2015_function_name.rs @@ -57,7 +57,7 @@ test!( r#"number = function (x) { return x; };"#, - r#"number = function number(x) { + r#"number = function number1(x) { return x; };"# ); diff --git a/crates/swc_ecma_transforms_compat/src/es2015/function_name.rs b/crates/swc_ecma_transforms_compat/src/es2015/function_name.rs index 85cf0d152fe..0ad7421deac 100644 --- a/crates/swc_ecma_transforms_compat/src/es2015/function_name.rs +++ b/crates/swc_ecma_transforms_compat/src/es2015/function_name.rs @@ -1,4 +1,4 @@ -use swc_common::util::take::Take; +use swc_common::{util::take::Take, DUMMY_SP}; use swc_ecma_ast::*; use swc_ecma_transforms_base::perf::Parallel; use swc_ecma_utils::{private_ident, IdentUsageFinder}; @@ -118,7 +118,7 @@ macro_rules! impl_for { // self.name = Some(name); node.ident = None; } else { - node.ident = Some(name); + node.ident = Some(private_ident!(DUMMY_SP, name.sym)); } } }