From 8df6e047cc523088a26a3363fe33f1bc224738b0 Mon Sep 17 00:00:00 2001 From: magic-akari Date: Mon, 4 Jul 2022 11:49:52 +0800 Subject: [PATCH] fix(es/codegen): Emit numeric value for Binary and Octal literals (#5083) --- .../fixture/issues-4xxx/4870/1/input/.swcrc | 12 ++ .../fixture/issues-4xxx/4870/1/input/index.js | 4 + .../issues-4xxx/4870/1/output/index.js | 5 + .../issues-4xxx/4870/1/output/index.map | 13 ++ .../fixture/issues-4xxx/4870/2/input/.swcrc | 12 ++ .../fixture/issues-4xxx/4870/2/input/index.js | 5 + .../issues-4xxx/4870/2/output/index.js | 6 + .../issues-4xxx/4870/2/output/index.map | 13 ++ .../binaryIntegerLiteralES6_es5.1.normal.js | 20 +-- .../binaryIntegerLiteralES6_es5.2.minified.js | 20 +-- .../binaryIntegerLiteral_es5.1.normal.js | 20 +-- .../binaryIntegerLiteral_es5.2.minified.js | 20 +-- ...thLiteralPropertyNameInES6_es5.1.normal.js | 10 +- ...LiteralPropertyNameInES6_es5.2.minified.js | 6 +- .../octalIntegerLiteralES6_es5.1.normal.js | 20 +-- .../octalIntegerLiteralES6_es5.2.minified.js | 20 +-- .../octalIntegerLiteral_es5.1.normal.js | 20 +-- .../octalIntegerLiteral_es5.2.minified.js | 20 +-- ...r.numericSeparators.binary_es5.1.normal.js | 8 +- ...er.numericSeparators.octal_es5.1.normal.js | 8 +- ...yAccessNumericLiterals.es6_es5.1.normal.js | 4 +- ...ccessNumericLiterals.es6_es5.2.minified.js | 2 +- crates/swc_ecma_codegen/src/lib.rs | 147 ++++++++++-------- .../tests/fixture/number/input.js | 3 +- .../tests/fixture/number/output.js | 3 +- .../tests/fixture/number/output.min.js | 2 +- .../tests/test262/0f9f10c894a7d811.js | 2 +- .../tests/test262/15dfd62aa10c8b18.js | 2 +- .../tests/test262/1819ffb142e9c5ea.js | 2 +- .../tests/test262/1fbf374c8a04fb23.js | 2 +- .../tests/test262/2b9d4a632590814a.js | 2 +- .../tests/test262/32b6854d07aefbda.js | 2 +- .../tests/test262/37ac3bcee6fa89f9.js | 2 +- .../tests/test262/3b9779d2e19376a1.js | 2 +- .../tests/test262/4c2a2b32f0470048.js | 2 +- .../tests/test262/4e07f8992cca7db0.js | 2 +- .../tests/test262/62541961bcef8d79.js | 2 +- .../tests/test262/68125aef6f5cc46f.js | 2 +- .../tests/test262/756579211447db0b.js | 2 +- .../tests/test262/8fcaa7f3f8926a5e.js | 2 +- .../tests/test262/993584ec37388320.js | 2 +- .../tests/test262/a8fea31fe6aa588e.js | 2 +- .../tests/test262/c5328483d3ccadd0.js | 2 +- .../tests/test262/dc43022b3729abd1.js | 2 +- .../tests/test262/e0f831f2b08fd35c.js | 8 +- .../tests/test262/fdb684acf63f6274.js | 2 +- 46 files changed, 282 insertions(+), 187 deletions(-) create mode 100644 crates/swc/tests/fixture/issues-4xxx/4870/1/input/.swcrc create mode 100644 crates/swc/tests/fixture/issues-4xxx/4870/1/input/index.js create mode 100644 crates/swc/tests/fixture/issues-4xxx/4870/1/output/index.js create mode 100644 crates/swc/tests/fixture/issues-4xxx/4870/1/output/index.map create mode 100644 crates/swc/tests/fixture/issues-4xxx/4870/2/input/.swcrc create mode 100644 crates/swc/tests/fixture/issues-4xxx/4870/2/input/index.js create mode 100644 crates/swc/tests/fixture/issues-4xxx/4870/2/output/index.js create mode 100644 crates/swc/tests/fixture/issues-4xxx/4870/2/output/index.map diff --git a/crates/swc/tests/fixture/issues-4xxx/4870/1/input/.swcrc b/crates/swc/tests/fixture/issues-4xxx/4870/1/input/.swcrc new file mode 100644 index 00000000000..abf51982c7f --- /dev/null +++ b/crates/swc/tests/fixture/issues-4xxx/4870/1/input/.swcrc @@ -0,0 +1,12 @@ +{ + "jsc": { + "target": "es5", + "parser": { + "syntax": "ecmascript" + } + }, + "module": { + "type": "commonjs" + }, + "sourceMaps": true +} \ No newline at end of file diff --git a/crates/swc/tests/fixture/issues-4xxx/4870/1/input/index.js b/crates/swc/tests/fixture/issues-4xxx/4870/1/input/index.js new file mode 100644 index 00000000000..ffa3a584a10 --- /dev/null +++ b/crates/swc/tests/fixture/issues-4xxx/4870/1/input/index.js @@ -0,0 +1,4 @@ +function test() { + return 0b1_1111_0111 === 503 && 0o767 === 503; +} +test(); diff --git a/crates/swc/tests/fixture/issues-4xxx/4870/1/output/index.js b/crates/swc/tests/fixture/issues-4xxx/4870/1/output/index.js new file mode 100644 index 00000000000..20cb2cbcd9b --- /dev/null +++ b/crates/swc/tests/fixture/issues-4xxx/4870/1/output/index.js @@ -0,0 +1,5 @@ +"use strict"; +function test() { + return 503 === 503 && 503 === 503; +} +test(); diff --git a/crates/swc/tests/fixture/issues-4xxx/4870/1/output/index.map b/crates/swc/tests/fixture/issues-4xxx/4870/1/output/index.map new file mode 100644 index 00000000000..02c5123e64d --- /dev/null +++ b/crates/swc/tests/fixture/issues-4xxx/4870/1/output/index.map @@ -0,0 +1,13 @@ +{ + "mappings": "AAAA;AAAA,SAASA,IAAI,GAAG;IACZ,OAAO,GAAa,KAAK,GAAG,IAAI,GAAK,KAAK,GAAG,CAAC;CACjD;AACDA,IAAI,EAAE,CAAC", + "names": [ + "test" + ], + "sources": [ + "../../input/index.js" + ], + "sourcesContent": [ + "function test() {\n return 0b1_1111_0111 === 503 && 0o767 === 503;\n}\ntest();\n" + ], + "version": 3 +} diff --git a/crates/swc/tests/fixture/issues-4xxx/4870/2/input/.swcrc b/crates/swc/tests/fixture/issues-4xxx/4870/2/input/.swcrc new file mode 100644 index 00000000000..6a87ee34b56 --- /dev/null +++ b/crates/swc/tests/fixture/issues-4xxx/4870/2/input/.swcrc @@ -0,0 +1,12 @@ +{ + "jsc": { + "target": "es2020", + "parser": { + "syntax": "ecmascript" + } + }, + "module": { + "type": "commonjs" + }, + "sourceMaps": true +} \ No newline at end of file diff --git a/crates/swc/tests/fixture/issues-4xxx/4870/2/input/index.js b/crates/swc/tests/fixture/issues-4xxx/4870/2/input/index.js new file mode 100644 index 00000000000..8aebe97ea30 --- /dev/null +++ b/crates/swc/tests/fixture/issues-4xxx/4870/2/input/index.js @@ -0,0 +1,5 @@ +function test() { + // only remove number separators, but keep Binary literals + return 0b1_1111_0111 === 503 && 0o767 === 503; +} +test(); diff --git a/crates/swc/tests/fixture/issues-4xxx/4870/2/output/index.js b/crates/swc/tests/fixture/issues-4xxx/4870/2/output/index.js new file mode 100644 index 00000000000..dc9bce444d3 --- /dev/null +++ b/crates/swc/tests/fixture/issues-4xxx/4870/2/output/index.js @@ -0,0 +1,6 @@ +"use strict"; +function test() { + // only remove number separators, but keep Binary literals + return 0b111110111 === 503 && 0o767 === 503; +} +test(); diff --git a/crates/swc/tests/fixture/issues-4xxx/4870/2/output/index.map b/crates/swc/tests/fixture/issues-4xxx/4870/2/output/index.map new file mode 100644 index 00000000000..09a52647169 --- /dev/null +++ b/crates/swc/tests/fixture/issues-4xxx/4870/2/output/index.map @@ -0,0 +1,13 @@ +{ + "mappings": "AAAA;AAAA,SAASA,IAAI,GAAG;IACZ,0DAA0D;IAC1D,OAAO,WAAa,KAAK,GAAG,IAAI,KAAK,KAAK,GAAG,CAAC;CACjD;AACDA,IAAI,EAAE,CAAC", + "names": [ + "test" + ], + "sources": [ + "../../input/index.js" + ], + "sourcesContent": [ + "function test() {\n // only remove number separators, but keep Binary literals\n return 0b1_1111_0111 === 503 && 0o767 === 503;\n}\ntest();\n" + ], + "version": 3 +} diff --git a/crates/swc/tests/tsc-references/binaryIntegerLiteralES6_es5.1.normal.js b/crates/swc/tests/tsc-references/binaryIntegerLiteralES6_es5.1.normal.js index c70882dce17..a9475f94c3b 100644 --- a/crates/swc/tests/tsc-references/binaryIntegerLiteralES6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/binaryIntegerLiteralES6_es5.1.normal.js @@ -1,23 +1,23 @@ // @target: es6 -var bin1 = 0b11010; -var bin2 = 0B11010; -var bin3 = 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111; +var bin1 = 26; +var bin2 = 26; +var bin3 = 9671406556917009000000000; var bin4 = Infinity; var obj1 = { - 0b11010: "Hello", + 26: "Hello", a: bin1, bin1: bin1, - b: 0b11010, + b: 26, Infinity: true }; var obj2 = { - 0B11010: "World", + 26: "World", a: bin2, bin2: bin2, - b: 0B11010, - 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111: false + b: 26, + 9671406556917009000000000: false }; -obj1[0b11010]; // string +obj1[26]; // string obj1[26]; // string obj1["26"]; // string obj1["0b11010"]; // any @@ -25,7 +25,7 @@ obj1["a"]; // number obj1["b"]; // number obj1["bin1"]; // number obj1["Infinity"]; // boolean -obj2[0B11010]; // string +obj2[26]; // string obj2[26]; // string obj2["26"]; // string obj2["0B11010"]; // any diff --git a/crates/swc/tests/tsc-references/binaryIntegerLiteralES6_es5.2.minified.js b/crates/swc/tests/tsc-references/binaryIntegerLiteralES6_es5.2.minified.js index ec5b47f3863..36443cad17f 100644 --- a/crates/swc/tests/tsc-references/binaryIntegerLiteralES6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/binaryIntegerLiteralES6_es5.2.minified.js @@ -1,14 +1,14 @@ var obj1 = { - 0b11010: "Hello", - a: 0b11010, - bin1: 0b11010, - b: 0b11010, + 26: "Hello", + a: 26, + bin1: 26, + b: 26, Infinity: !0 }, obj2 = { - 0B11010: "World", - a: 0B11010, - bin2: 0B11010, - b: 0B11010, - 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111: !1 + 26: "World", + a: 26, + bin2: 26, + b: 26, + 9671406556917009000000000: !1 }; -obj1[0b11010], obj1[26], obj1["26"], obj1["0b11010"], obj1.a, obj1.b, obj1.bin1, obj1.Infinity, obj2[0B11010], obj2[26], obj2["26"], obj2["0B11010"], obj2.a, obj2.b, obj2.bin2, obj2[9.671406556917009e+24], obj2["9.671406556917009e+24"], obj2.Infinity; +obj1[26], obj1[26], obj1["26"], obj1["0b11010"], obj1.a, obj1.b, obj1.bin1, obj1.Infinity, obj2[26], obj2[26], obj2["26"], obj2["0B11010"], obj2.a, obj2.b, obj2.bin2, obj2[9.671406556917009e+24], obj2["9.671406556917009e+24"], obj2.Infinity; diff --git a/crates/swc/tests/tsc-references/binaryIntegerLiteral_es5.1.normal.js b/crates/swc/tests/tsc-references/binaryIntegerLiteral_es5.1.normal.js index 8002290db24..6fb92119f25 100644 --- a/crates/swc/tests/tsc-references/binaryIntegerLiteral_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/binaryIntegerLiteral_es5.1.normal.js @@ -1,23 +1,23 @@ // @target: es5 -var bin1 = 0b11010; -var bin2 = 0B11010; -var bin3 = 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111; +var bin1 = 26; +var bin2 = 26; +var bin3 = 9671406556917009000000000; var bin4 = Infinity; var obj1 = { - 0b11010: "Hello", + 26: "Hello", a: bin1, bin1: bin1, - b: 0b11010, + b: 26, Infinity: true }; var obj2 = { - 0B11010: "World", + 26: "World", a: bin2, bin2: bin2, - b: 0B11010, - 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111: false + b: 26, + 9671406556917009000000000: false }; -obj1[0b11010]; // string +obj1[26]; // string obj1[26]; // string obj1["26"]; // string obj1["0b11010"]; // any @@ -25,7 +25,7 @@ obj1["a"]; // number obj1["b"]; // number obj1["bin1"]; // number obj1["Infinity"]; // boolean -obj2[0B11010]; // string +obj2[26]; // string obj2[26]; // string obj2["26"]; // string obj2["0B11010"]; // any diff --git a/crates/swc/tests/tsc-references/binaryIntegerLiteral_es5.2.minified.js b/crates/swc/tests/tsc-references/binaryIntegerLiteral_es5.2.minified.js index ec5b47f3863..36443cad17f 100644 --- a/crates/swc/tests/tsc-references/binaryIntegerLiteral_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/binaryIntegerLiteral_es5.2.minified.js @@ -1,14 +1,14 @@ var obj1 = { - 0b11010: "Hello", - a: 0b11010, - bin1: 0b11010, - b: 0b11010, + 26: "Hello", + a: 26, + bin1: 26, + b: 26, Infinity: !0 }, obj2 = { - 0B11010: "World", - a: 0B11010, - bin2: 0B11010, - b: 0B11010, - 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111: !1 + 26: "World", + a: 26, + bin2: 26, + b: 26, + 9671406556917009000000000: !1 }; -obj1[0b11010], obj1[26], obj1["26"], obj1["0b11010"], obj1.a, obj1.b, obj1.bin1, obj1.Infinity, obj2[0B11010], obj2[26], obj2["26"], obj2["0B11010"], obj2.a, obj2.b, obj2.bin2, obj2[9.671406556917009e+24], obj2["9.671406556917009e+24"], obj2.Infinity; +obj1[26], obj1[26], obj1["26"], obj1["0b11010"], obj1.a, obj1.b, obj1.bin1, obj1.Infinity, obj2[26], obj2[26], obj2["26"], obj2["0B11010"], obj2.a, obj2.b, obj2.bin2, obj2[9.671406556917009e+24], obj2["9.671406556917009e+24"], obj2.Infinity; diff --git a/crates/swc/tests/tsc-references/emitClassDeclarationWithLiteralPropertyNameInES6_es5.1.normal.js b/crates/swc/tests/tsc-references/emitClassDeclarationWithLiteralPropertyNameInES6_es5.1.normal.js index a29fe72122a..cf55c71ebaf 100644 --- a/crates/swc/tests/tsc-references/emitClassDeclarationWithLiteralPropertyNameInES6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/emitClassDeclarationWithLiteralPropertyNameInES6_es5.1.normal.js @@ -5,18 +5,18 @@ var B = /*#__PURE__*/ function() { function B() { _class_call_check(this, B); this["hello"] = 10; - this[0b110] = "world"; - this[0o23534] = "WORLD"; + this[6] = "world"; + this[10076] = "WORLD"; this[20] = "twenty"; } var _proto = B.prototype; _proto["foo"] = function foo() {}; - _proto[0b1110] = function() {}; + _proto[14] = function() {}; _proto[11] = function() {}; _proto.interface = function _interface() {}; return B; }(); B["hi"] = 10000; B[22] = "twenty-two"; -B[0b101] = "binary"; -B[0o3235] = "octal"; +B[5] = "binary"; +B[1693] = "octal"; diff --git a/crates/swc/tests/tsc-references/emitClassDeclarationWithLiteralPropertyNameInES6_es5.2.minified.js b/crates/swc/tests/tsc-references/emitClassDeclarationWithLiteralPropertyNameInES6_es5.2.minified.js index eafed3e51ee..7d3bbdaae93 100644 --- a/crates/swc/tests/tsc-references/emitClassDeclarationWithLiteralPropertyNameInES6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/emitClassDeclarationWithLiteralPropertyNameInES6_es5.2.minified.js @@ -2,9 +2,9 @@ import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; var B = function() { "use strict"; function B() { - _class_call_check(this, B), this.hello = 10, this[0b110] = "world", this[0o23534] = "WORLD", this[20] = "twenty"; + _class_call_check(this, B), this.hello = 10, this[6] = "world", this[10076] = "WORLD", this[20] = "twenty"; } var _proto = B.prototype; - return _proto.foo = function() {}, _proto[0b1110] = function() {}, _proto[11] = function() {}, _proto.interface = function() {}, B; + return _proto.foo = function() {}, _proto[14] = function() {}, _proto[11] = function() {}, _proto.interface = function() {}, B; }(); -B.hi = 10000, B[22] = "twenty-two", B[0b101] = "binary", B[0o3235] = "octal"; +B.hi = 10000, B[22] = "twenty-two", B[5] = "binary", B[1693] = "octal"; diff --git a/crates/swc/tests/tsc-references/octalIntegerLiteralES6_es5.1.normal.js b/crates/swc/tests/tsc-references/octalIntegerLiteralES6_es5.1.normal.js index 22bdf66925d..47a92ed980b 100644 --- a/crates/swc/tests/tsc-references/octalIntegerLiteralES6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/octalIntegerLiteralES6_es5.1.normal.js @@ -1,23 +1,23 @@ // @target: es6 -var oct1 = 0o45436; -var oct2 = 0O45436; +var oct1 = 19230; +var oct2 = 19230; var oct3 = Infinity; -var oct4 = 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777; +var oct4 = 54624374234151770000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000; var obj1 = { - 0o45436: "Hello", - a: 0o45436, + 19230: "Hello", + a: 19230, b: oct1, oct1: oct1, Infinity: true }; var obj2 = { - 0O45436: "hi", - a: 0O45436, + 19230: "hi", + a: 19230, b: oct2, oct2: oct2, - 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: false + 54624374234151770000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000: false }; -obj1[0o45436]; // string +obj1[19230]; // string obj1["0o45436"]; // any obj1["19230"]; // string obj1[19230]; // string @@ -25,7 +25,7 @@ obj1["a"]; // number obj1["b"]; // number obj1["oct1"]; // number obj1["Infinity"]; // boolean -obj2[0O45436]; // string +obj2[19230]; // string obj2["0O45436"]; // any obj2["19230"]; // string obj2[19230]; // string diff --git a/crates/swc/tests/tsc-references/octalIntegerLiteralES6_es5.2.minified.js b/crates/swc/tests/tsc-references/octalIntegerLiteralES6_es5.2.minified.js index b395fc8cd7e..1a4b19087d7 100644 --- a/crates/swc/tests/tsc-references/octalIntegerLiteralES6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/octalIntegerLiteralES6_es5.2.minified.js @@ -1,14 +1,14 @@ var obj1 = { - 0o45436: "Hello", - a: 0o45436, - b: 0o45436, - oct1: 0o45436, + 19230: "Hello", + a: 19230, + b: 19230, + oct1: 19230, Infinity: !0 }, obj2 = { - 0O45436: "hi", - a: 0O45436, - b: 0O45436, - oct2: 0O45436, - 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: !1 + 19230: "hi", + a: 19230, + b: 19230, + oct2: 19230, + 54624374234151770000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000: !1 }; -obj1[0o45436], obj1["0o45436"], obj1["19230"], obj1[19230], obj1.a, obj1.b, obj1.oct1, obj1.Infinity, obj2[0O45436], obj2["0O45436"], obj2["19230"], obj2[19230], obj2.a, obj2.b, obj2.oct2, obj2[5.462437423415177e+244], obj2["5.462437423415177e+244"], obj2.Infinity; +obj1[19230], obj1["0o45436"], obj1["19230"], obj1[19230], obj1.a, obj1.b, obj1.oct1, obj1.Infinity, obj2[19230], obj2["0O45436"], obj2["19230"], obj2[19230], obj2.a, obj2.b, obj2.oct2, obj2[5.462437423415177e+244], obj2["5.462437423415177e+244"], obj2.Infinity; diff --git a/crates/swc/tests/tsc-references/octalIntegerLiteral_es5.1.normal.js b/crates/swc/tests/tsc-references/octalIntegerLiteral_es5.1.normal.js index e6f4fb7bea5..039bdc4e8b6 100644 --- a/crates/swc/tests/tsc-references/octalIntegerLiteral_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/octalIntegerLiteral_es5.1.normal.js @@ -1,23 +1,23 @@ // @target: es5 -var oct1 = 0o45436; -var oct2 = 0O45436; +var oct1 = 19230; +var oct2 = 19230; var oct3 = Infinity; -var oct4 = 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777; +var oct4 = 54624374234151770000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000; var obj1 = { - 0o45436: "Hello", - a: 0o45436, + 19230: "Hello", + a: 19230, b: oct1, oct1: oct1, Infinity: true }; var obj2 = { - 0O45436: "hi", - a: 0O45436, + 19230: "hi", + a: 19230, b: oct2, oct2: oct2, - 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: false + 54624374234151770000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000: false }; -obj1[0o45436]; // string +obj1[19230]; // string obj1["0o45436"]; // any obj1["19230"]; // string obj1[19230]; // string @@ -25,7 +25,7 @@ obj1["a"]; // number obj1["b"]; // number obj1["oct1"]; // number obj1["Infinity"]; // boolean -obj2[0O45436]; // string +obj2[19230]; // string obj2["0O45436"]; // any obj2["19230"]; // string obj2[19230]; // string diff --git a/crates/swc/tests/tsc-references/octalIntegerLiteral_es5.2.minified.js b/crates/swc/tests/tsc-references/octalIntegerLiteral_es5.2.minified.js index b395fc8cd7e..1a4b19087d7 100644 --- a/crates/swc/tests/tsc-references/octalIntegerLiteral_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/octalIntegerLiteral_es5.2.minified.js @@ -1,14 +1,14 @@ var obj1 = { - 0o45436: "Hello", - a: 0o45436, - b: 0o45436, - oct1: 0o45436, + 19230: "Hello", + a: 19230, + b: 19230, + oct1: 19230, Infinity: !0 }, obj2 = { - 0O45436: "hi", - a: 0O45436, - b: 0O45436, - oct2: 0O45436, - 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: !1 + 19230: "hi", + a: 19230, + b: 19230, + oct2: 19230, + 54624374234151770000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000: !1 }; -obj1[0o45436], obj1["0o45436"], obj1["19230"], obj1[19230], obj1.a, obj1.b, obj1.oct1, obj1.Infinity, obj2[0O45436], obj2["0O45436"], obj2["19230"], obj2[19230], obj2.a, obj2.b, obj2.oct2, obj2[5.462437423415177e+244], obj2["5.462437423415177e+244"], obj2.Infinity; +obj1[19230], obj1["0o45436"], obj1["19230"], obj1[19230], obj1.a, obj1.b, obj1.oct1, obj1.Infinity, obj2[19230], obj2["0O45436"], obj2["19230"], obj2[19230], obj2.a, obj2.b, obj2.oct2, obj2[5.462437423415177e+244], obj2["5.462437423415177e+244"], obj2.Infinity; diff --git a/crates/swc/tests/tsc-references/parser.numericSeparators.binary_es5.1.normal.js b/crates/swc/tests/tsc-references/parser.numericSeparators.binary_es5.1.normal.js index fb1f7a453c2..3278dd7ed39 100644 --- a/crates/swc/tests/tsc-references/parser.numericSeparators.binary_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/parser.numericSeparators.binary_es5.1.normal.js @@ -1,4 +1,4 @@ -0b0011; -0B01; -0b11000011; -0B0110101; +3; +1; +195; +53; diff --git a/crates/swc/tests/tsc-references/parser.numericSeparators.octal_es5.1.normal.js b/crates/swc/tests/tsc-references/parser.numericSeparators.octal_es5.1.normal.js index cefe24b801d..37fd645a14a 100644 --- a/crates/swc/tests/tsc-references/parser.numericSeparators.octal_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/parser.numericSeparators.octal_es5.1.normal.js @@ -1,4 +1,4 @@ -0o0011; -0O01; -0o11000011; -0O0110101; +9; +1; +2359305; +36929; diff --git a/crates/swc/tests/tsc-references/propertyAccessNumericLiterals.es6_es5.1.normal.js b/crates/swc/tests/tsc-references/propertyAccessNumericLiterals.es6_es5.1.normal.js index 8ed7d60e832..cc80f625d50 100644 --- a/crates/swc/tests/tsc-references/propertyAccessNumericLiterals.es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/propertyAccessNumericLiterals.es6_es5.1.normal.js @@ -1,6 +1,6 @@ // @target: es6 0xffffffff.toString(); -0o01234.toString(); -0b01101101.toString(); +668..toString(); +109..toString(); 1234..toString(); 1e0.toString(); diff --git a/crates/swc/tests/tsc-references/propertyAccessNumericLiterals.es6_es5.2.minified.js b/crates/swc/tests/tsc-references/propertyAccessNumericLiterals.es6_es5.2.minified.js index f2d941d1cb3..d93da3c4e66 100644 --- a/crates/swc/tests/tsc-references/propertyAccessNumericLiterals.es6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/propertyAccessNumericLiterals.es6_es5.2.minified.js @@ -1 +1 @@ -0xffffffff.toString(), 0o01234.toString(), 0b01101101.toString(), 1234..toString(), 1e0.toString(); +0xffffffff.toString(), 668..toString(), 109..toString(), 1234..toString(), 1e0.toString(); diff --git a/crates/swc_ecma_codegen/src/lib.rs b/crates/swc_ecma_codegen/src/lib.rs index 9301ac8d8b2..c7762ea9c99 100644 --- a/crates/swc_ecma_codegen/src/lib.rs +++ b/crates/swc_ecma_codegen/src/lib.rs @@ -562,6 +562,16 @@ where #[emitter] fn emit_num_lit(&mut self, num: &Number) -> Result { + self.emit_num_lit_internal(num, false)?; + } + + /// `1.toString` is an invalid property access, + /// should emit a dot after the literal if return true + fn emit_num_lit_internal( + &mut self, + num: &Number, + detect_dot: bool, + ) -> std::result::Result { self.emit_leading_comments_of_span(num.span(), false)?; // Handle infinity @@ -570,24 +580,78 @@ where self.wr.write_str_lit(num.span, "-")?; } self.wr.write_str_lit(num.span, "Infinity")?; - } else if self.cfg.minify { - let minified = minify_number(num.value); - self.wr.write_str_lit(num.span, &minified)?; + return Ok(false); + } + + let mut striped_raw = None; + let mut value = String::default(); + + if self.cfg.minify { + value = minify_number(num.value); + self.wr.write_str_lit(num.span, &value)?; } else { match &num.raw { Some(raw) => { - if self.cfg.target < EsVersion::Es2021 && raw.contains('_') { - self.wr.write_str_lit(num.span, &raw.replace('_', ""))?; + if raw.len() > 2 && self.cfg.target < EsVersion::Es2015 && { + let slice = &raw.as_bytes()[..2]; + slice == b"0b" || slice == b"0o" || slice == b"0B" || slice == b"0O" + } { + value = num.value.to_string(); + self.wr.write_str_lit(num.span, &value)?; + } else if raw.len() > 2 + && self.cfg.target < EsVersion::Es2021 + && raw.contains('_') + { + let value = raw.replace('_', ""); + self.wr.write_str_lit(num.span, &value)?; + + striped_raw = Some(value); } else { self.wr.write_str_lit(num.span, raw)?; + + if !detect_dot { + return Ok(false); + } + + striped_raw = Some(raw.replace('_', "")); } } _ => { - self.wr.write_str_lit(num.span, &num.value.to_string())?; + value = num.value.to_string(); + self.wr.write_str_lit(num.span, &value)?; } } } + + // fast return + if !detect_dot { + return Ok(false); + } + + Ok(striped_raw + .map(|raw| { + if raw.bytes().all(|c| c.is_ascii_digit()) { + // Legacy octal contains only digits, but `value` and `raw` are + // different + if !num.value.to_string().eq(&raw) { + return false; + } + + return true; + } + + false + }) + .unwrap_or_else(|| { + let bytes = value.as_bytes(); + + if !bytes.contains(&b'.') && !bytes.contains(&b'e') { + return true; + } + + false + })) } #[emitter] @@ -600,7 +664,7 @@ where } else { match &v.raw { Some(raw) => { - if self.cfg.target < EsVersion::Es2021 && raw.contains('_') { + if raw.len() > 2 && self.cfg.target < EsVersion::Es2021 && raw.contains('_') { self.wr.write_str_lit(v.span, &raw.replace('_', ""))?; } else { self.wr.write_str_lit(v.span, raw)?; @@ -814,16 +878,24 @@ where srcmap!(node, true); - if let Expr::New(new) = &*node.obj { - self.emit_new(new, false)?; - } else { - emit!(node.obj); + let mut needs_2dots_for_property_access = false; + + match &*node.obj { + Expr::New(new) => { + self.emit_new(new, false)?; + } + Expr::Lit(Lit::Num(num)) => { + needs_2dots_for_property_access = self.emit_num_lit_internal(num, true)?; + } + _ => { + emit!(node.obj); + } } match &node.prop { MemberProp::Computed(computed) => emit!(computed), MemberProp::Ident(ident) => { - if self.needs_2dots_for_property_access(&node.obj) { + if needs_2dots_for_property_access { if node.prop.span().lo() >= BytePos(2) { self.emit_leading_comments(node.prop.span().lo() - BytePos(2), false)?; } @@ -836,7 +908,7 @@ where emit!(ident); } MemberProp::PrivateName(private) => { - if self.needs_2dots_for_property_access(&node.obj) { + if needs_2dots_for_property_access { if node.prop.span().lo() >= BytePos(2) { self.emit_leading_comments(node.prop.span().lo() - BytePos(2), false)?; } @@ -853,55 +925,6 @@ where srcmap!(node, false); } - /// `1..toString` is a valid property access, emit a dot after the literal - pub fn needs_2dots_for_property_access(&self, expr: &Expr) -> bool { - if let Expr::Lit(Lit::Num(Number { span, value, raw })) = expr { - // TODO we store `NaN` in `swc_ecma_minifier`, but we should not do it - if value.is_nan() || value.is_infinite() { - return false; - } - - if self.cfg.minify { - let s = minify_number(*value); - let bytes = s.as_bytes(); - - if !bytes.contains(&b'.') && !bytes.contains(&b'e') { - return true; - } - - false - } else { - match raw { - Some(raw) => { - if raw.bytes().all(|c| c.is_ascii_digit()) { - // Legacy octal contains only digits, but `value` and `raw` are - // different - if !value.to_string().eq(raw.as_ref()) { - return false; - } - - return true; - } - - false - } - _ => { - let s = value.to_string(); - let bytes = s.as_bytes(); - - if !bytes.contains(&b'.') && !bytes.contains(&b'e') { - return true; - } - - false - } - } - } - } else { - false - } - } - #[emitter] fn emit_super_expr(&mut self, node: &SuperPropExpr) -> Result { self.emit_leading_comments_of_span(node.span(), false)?; diff --git a/crates/swc_ecma_codegen/tests/fixture/number/input.js b/crates/swc_ecma_codegen/tests/fixture/number/input.js index 47bd36bc1ee..3b9230c208d 100644 --- a/crates/swc_ecma_codegen/tests/fixture/number/input.js +++ b/crates/swc_ecma_codegen/tests/fixture/number/input.js @@ -57,7 +57,7 @@ const foo39 = 0.00001543000; const foo40 = (0.00001543000); const foo41 = { 1000050000: "foo" }; const foo42 = 1000000003242; -const foo43 = -1000000003242; +const foo43_ = -1000000003242; const foo43 = 0.0; const foo44 = -0.0; const foo45 = +0.0; @@ -114,6 +114,7 @@ const hugefoo = 1000000000001..test(); const hugefoo1 = 0xEE.test(); 1_2_3_4..toString(); +1_2_3_4 .toString(); const foo72 = 86400000; const foo73 = 65535; diff --git a/crates/swc_ecma_codegen/tests/fixture/number/output.js b/crates/swc_ecma_codegen/tests/fixture/number/output.js index 288efbfd22a..627aa8822e5 100644 --- a/crates/swc_ecma_codegen/tests/fixture/number/output.js +++ b/crates/swc_ecma_codegen/tests/fixture/number/output.js @@ -59,7 +59,7 @@ const foo41 = { 1000050000: "foo" }; const foo42 = 1000000003242; -const foo43 = -1000000003242; +const foo43_ = -1000000003242; const foo43 = 0.0; const foo44 = -0.0; const foo45 = +0.0; @@ -106,6 +106,7 @@ const foo71 = 0XfF; const hugefoo = 1000000000001..test(); const hugefoo1 = 0xEE.test(); 1_2_3_4..toString(); +1_2_3_4..toString(); const foo72 = 86400000; const foo73 = 65535; const foo74 = 0xffff; diff --git a/crates/swc_ecma_codegen/tests/fixture/number/output.min.js b/crates/swc_ecma_codegen/tests/fixture/number/output.min.js index e4cb33f2eb2..e02e325c8c0 100644 --- a/crates/swc_ecma_codegen/tests/fixture/number/output.min.js +++ b/crates/swc_ecma_codegen/tests/fixture/number/output.min.js @@ -1 +1 @@ -const exp=1e3;const Exp=1e12;const negativeExp=1e-8;const huge=0xe8d4a51001;const big=100000000001;const fractional=100.23002;const numeric_separators=1e12;const one=1e3;const two=1e6;const three=-1e6;const bin=85;const oct=342391;const hex=3735928559;const fractional2=1000.0001;const identifier=_1000;const negate_identifier=-_1000;const foo=.1;const foo1=+.1;const foo2=-.1;const foo3=1050;const foo4=100500;const foo5=10005e3;const foo6=100005e4;const foo7=.1;const foo8=.01;const foo9=.001;const foo10=1e-4;const foo11=1e-5;const foo12=1e-6;const foo13=24e-6;const foo14=-24e-6;const foo15=10;const foo16=100;const foo17=1e3;const foo18=1e4;const foo19=1e5;const foo20=.1;const foo21=.01;const foo22=.001;const foo23=1e-4;const foo24=1e-5;const foo25=-.1;const foo26=-.01;const foo27=-.001;const foo28=-1e-4;const foo29=-1e-5;const foo30=.001;const foo31=.00321;const foo32=321e-6;const foo33=.1;const foo34=1e-5;const foo35=0;const foo36=-0;const foo37=+0;const foo38=1543e-8;const foo39=1543e-8;const foo40=(1543e-8);const foo41={100005e4:"foo"};const foo42=0xe8d4a51caa;const foo43=-0xe8d4a51caa;const foo43=0;const foo44=-0;const foo45=+0;const foo46=1e9;const foo47=1.10001;const foo48=1e10;const foo49=1e10;const foo50=1e-10;const foo51=11e99;const foo52=11e99;const foo53=11e-101;const foo54=123456;const foo55=122333;const foo56=12.34;const foo57=1234e54;const foo58=1234e54;const foo59=1234e-58;const foo60=.1;const foo61=10;const foo62=5e9;const foo63=255;const foo64=255;const foo65=255;const foo66=0;const foo67=0;const foo68=0;const foo69=0;const foo70=0;const foo71=255;26..toString();4294967295..toString();4294967295..toString();668..toString();668..toString();109..toString();109..toString();1234..toString();1..toString();77..toExponential();77..toExponential();(77).toExponential();77..toExponential();77..toExponential();const hugefoo=0xe8d4a51001.test();const hugefoo1=238..test();1234..toString();const foo72=864e5;const foo73=65535;const foo74=65535;const foo75=Infinity;const foo76=Infinity.toString() +const exp=1e3;const Exp=1e12;const negativeExp=1e-8;const huge=0xe8d4a51001;const big=100000000001;const fractional=100.23002;const numeric_separators=1e12;const one=1e3;const two=1e6;const three=-1e6;const bin=85;const oct=342391;const hex=3735928559;const fractional2=1000.0001;const identifier=_1000;const negate_identifier=-_1000;const foo=.1;const foo1=+.1;const foo2=-.1;const foo3=1050;const foo4=100500;const foo5=10005e3;const foo6=100005e4;const foo7=.1;const foo8=.01;const foo9=.001;const foo10=1e-4;const foo11=1e-5;const foo12=1e-6;const foo13=24e-6;const foo14=-24e-6;const foo15=10;const foo16=100;const foo17=1e3;const foo18=1e4;const foo19=1e5;const foo20=.1;const foo21=.01;const foo22=.001;const foo23=1e-4;const foo24=1e-5;const foo25=-.1;const foo26=-.01;const foo27=-.001;const foo28=-1e-4;const foo29=-1e-5;const foo30=.001;const foo31=.00321;const foo32=321e-6;const foo33=.1;const foo34=1e-5;const foo35=0;const foo36=-0;const foo37=+0;const foo38=1543e-8;const foo39=1543e-8;const foo40=(1543e-8);const foo41={100005e4:"foo"};const foo42=0xe8d4a51caa;const foo43_=-0xe8d4a51caa;const foo43=0;const foo44=-0;const foo45=+0;const foo46=1e9;const foo47=1.10001;const foo48=1e10;const foo49=1e10;const foo50=1e-10;const foo51=11e99;const foo52=11e99;const foo53=11e-101;const foo54=123456;const foo55=122333;const foo56=12.34;const foo57=1234e54;const foo58=1234e54;const foo59=1234e-58;const foo60=.1;const foo61=10;const foo62=5e9;const foo63=255;const foo64=255;const foo65=255;const foo66=0;const foo67=0;const foo68=0;const foo69=0;const foo70=0;const foo71=255;26..toString();4294967295..toString();4294967295..toString();668..toString();668..toString();109..toString();109..toString();1234..toString();1..toString();77..toExponential();77..toExponential();(77).toExponential();77..toExponential();77..toExponential();const hugefoo=0xe8d4a51001.test();const hugefoo1=238..test();1234..toString();1234..toString();const foo72=864e5;const foo73=65535;const foo74=65535;const foo75=Infinity;const foo76=Infinity.toString() diff --git a/crates/swc_ecma_codegen/tests/test262/0f9f10c894a7d811.js b/crates/swc_ecma_codegen/tests/test262/0f9f10c894a7d811.js index 990584bb099..9c4c945a31c 100644 --- a/crates/swc_ecma_codegen/tests/test262/0f9f10c894a7d811.js +++ b/crates/swc_ecma_codegen/tests/test262/0f9f10c894a7d811.js @@ -1 +1 @@ -(0o0); +(0); diff --git a/crates/swc_ecma_codegen/tests/test262/15dfd62aa10c8b18.js b/crates/swc_ecma_codegen/tests/test262/15dfd62aa10c8b18.js index fd7a2e437ca..8bbe415a577 100644 --- a/crates/swc_ecma_codegen/tests/test262/15dfd62aa10c8b18.js +++ b/crates/swc_ecma_codegen/tests/test262/15dfd62aa10c8b18.js @@ -1,4 +1,4 @@ function a() { "use strict"; - 0O0; + 0; } diff --git a/crates/swc_ecma_codegen/tests/test262/1819ffb142e9c5ea.js b/crates/swc_ecma_codegen/tests/test262/1819ffb142e9c5ea.js index d52598404f9..0f57817f75f 100644 --- a/crates/swc_ecma_codegen/tests/test262/1819ffb142e9c5ea.js +++ b/crates/swc_ecma_codegen/tests/test262/1819ffb142e9c5ea.js @@ -1 +1 @@ -0O0; +0; diff --git a/crates/swc_ecma_codegen/tests/test262/1fbf374c8a04fb23.js b/crates/swc_ecma_codegen/tests/test262/1fbf374c8a04fb23.js index fbebe892287..688f63e4c8e 100644 --- a/crates/swc_ecma_codegen/tests/test262/1fbf374c8a04fb23.js +++ b/crates/swc_ecma_codegen/tests/test262/1fbf374c8a04fb23.js @@ -1 +1 @@ -0o10; +8; diff --git a/crates/swc_ecma_codegen/tests/test262/2b9d4a632590814a.js b/crates/swc_ecma_codegen/tests/test262/2b9d4a632590814a.js index 9df83eef85b..8bbe415a577 100644 --- a/crates/swc_ecma_codegen/tests/test262/2b9d4a632590814a.js +++ b/crates/swc_ecma_codegen/tests/test262/2b9d4a632590814a.js @@ -1,4 +1,4 @@ function a() { "use strict"; - 0o0; + 0; } diff --git a/crates/swc_ecma_codegen/tests/test262/32b6854d07aefbda.js b/crates/swc_ecma_codegen/tests/test262/32b6854d07aefbda.js index f6c4e4bbac0..0f57817f75f 100644 --- a/crates/swc_ecma_codegen/tests/test262/32b6854d07aefbda.js +++ b/crates/swc_ecma_codegen/tests/test262/32b6854d07aefbda.js @@ -1 +1 @@ -0B0; +0; diff --git a/crates/swc_ecma_codegen/tests/test262/37ac3bcee6fa89f9.js b/crates/swc_ecma_codegen/tests/test262/37ac3bcee6fa89f9.js index 874fa1e3f69..765da1143e1 100644 --- a/crates/swc_ecma_codegen/tests/test262/37ac3bcee6fa89f9.js +++ b/crates/swc_ecma_codegen/tests/test262/37ac3bcee6fa89f9.js @@ -1 +1 @@ -0b10; +2; diff --git a/crates/swc_ecma_codegen/tests/test262/3b9779d2e19376a1.js b/crates/swc_ecma_codegen/tests/test262/3b9779d2e19376a1.js index 39306374265..765da1143e1 100644 --- a/crates/swc_ecma_codegen/tests/test262/3b9779d2e19376a1.js +++ b/crates/swc_ecma_codegen/tests/test262/3b9779d2e19376a1.js @@ -1 +1 @@ -0o2; +2; diff --git a/crates/swc_ecma_codegen/tests/test262/4c2a2b32f0470048.js b/crates/swc_ecma_codegen/tests/test262/4c2a2b32f0470048.js index 10182e884f8..187cb3e3ef4 100644 --- a/crates/swc_ecma_codegen/tests/test262/4c2a2b32f0470048.js +++ b/crates/swc_ecma_codegen/tests/test262/4c2a2b32f0470048.js @@ -1 +1 @@ -0O12; +10; diff --git a/crates/swc_ecma_codegen/tests/test262/4e07f8992cca7db0.js b/crates/swc_ecma_codegen/tests/test262/4e07f8992cca7db0.js index 3df1566a30c..3979e1d9640 100644 --- a/crates/swc_ecma_codegen/tests/test262/4e07f8992cca7db0.js +++ b/crates/swc_ecma_codegen/tests/test262/4e07f8992cca7db0.js @@ -1,2 +1,2 @@ "use strict"; -0o0; +0; diff --git a/crates/swc_ecma_codegen/tests/test262/62541961bcef8d79.js b/crates/swc_ecma_codegen/tests/test262/62541961bcef8d79.js index e4c8c5dc031..0f57817f75f 100644 --- a/crates/swc_ecma_codegen/tests/test262/62541961bcef8d79.js +++ b/crates/swc_ecma_codegen/tests/test262/62541961bcef8d79.js @@ -1 +1 @@ -0b0; +0; diff --git a/crates/swc_ecma_codegen/tests/test262/68125aef6f5cc46f.js b/crates/swc_ecma_codegen/tests/test262/68125aef6f5cc46f.js index c874e476ce8..3979e1d9640 100644 --- a/crates/swc_ecma_codegen/tests/test262/68125aef6f5cc46f.js +++ b/crates/swc_ecma_codegen/tests/test262/68125aef6f5cc46f.js @@ -1,2 +1,2 @@ "use strict"; -0b0; +0; diff --git a/crates/swc_ecma_codegen/tests/test262/756579211447db0b.js b/crates/swc_ecma_codegen/tests/test262/756579211447db0b.js index 35a523d5fb1..765da1143e1 100644 --- a/crates/swc_ecma_codegen/tests/test262/756579211447db0b.js +++ b/crates/swc_ecma_codegen/tests/test262/756579211447db0b.js @@ -1 +1 @@ -0O2; +2; diff --git a/crates/swc_ecma_codegen/tests/test262/8fcaa7f3f8926a5e.js b/crates/swc_ecma_codegen/tests/test262/8fcaa7f3f8926a5e.js index f9e7c3e0715..0afc6045cfe 100644 --- a/crates/swc_ecma_codegen/tests/test262/8fcaa7f3f8926a5e.js +++ b/crates/swc_ecma_codegen/tests/test262/8fcaa7f3f8926a5e.js @@ -1 +1 @@ -0B1; +1; diff --git a/crates/swc_ecma_codegen/tests/test262/993584ec37388320.js b/crates/swc_ecma_codegen/tests/test262/993584ec37388320.js index f1f4e26a24c..0afc6045cfe 100644 --- a/crates/swc_ecma_codegen/tests/test262/993584ec37388320.js +++ b/crates/swc_ecma_codegen/tests/test262/993584ec37388320.js @@ -1 +1 @@ -0b1; +1; diff --git a/crates/swc_ecma_codegen/tests/test262/a8fea31fe6aa588e.js b/crates/swc_ecma_codegen/tests/test262/a8fea31fe6aa588e.js index 4a449d3e1eb..0afc6045cfe 100644 --- a/crates/swc_ecma_codegen/tests/test262/a8fea31fe6aa588e.js +++ b/crates/swc_ecma_codegen/tests/test262/a8fea31fe6aa588e.js @@ -1 +1 @@ -0o1; +1; diff --git a/crates/swc_ecma_codegen/tests/test262/c5328483d3ccadd0.js b/crates/swc_ecma_codegen/tests/test262/c5328483d3ccadd0.js index 56f4dd023e8..0f57817f75f 100644 --- a/crates/swc_ecma_codegen/tests/test262/c5328483d3ccadd0.js +++ b/crates/swc_ecma_codegen/tests/test262/c5328483d3ccadd0.js @@ -1 +1 @@ -0o0; +0; diff --git a/crates/swc_ecma_codegen/tests/test262/dc43022b3729abd1.js b/crates/swc_ecma_codegen/tests/test262/dc43022b3729abd1.js index 20d60b01c60..187cb3e3ef4 100644 --- a/crates/swc_ecma_codegen/tests/test262/dc43022b3729abd1.js +++ b/crates/swc_ecma_codegen/tests/test262/dc43022b3729abd1.js @@ -1 +1 @@ -0o12; +10; diff --git a/crates/swc_ecma_codegen/tests/test262/e0f831f2b08fd35c.js b/crates/swc_ecma_codegen/tests/test262/e0f831f2b08fd35c.js index 4fc3593e63b..eb6e4b2ed10 100644 --- a/crates/swc_ecma_codegen/tests/test262/e0f831f2b08fd35c.js +++ b/crates/swc_ecma_codegen/tests/test262/e0f831f2b08fd35c.js @@ -1,4 +1,4 @@ -0b1001; -0B1001; -0o11; -0O11; +9; +9; +9; +9; diff --git a/crates/swc_ecma_codegen/tests/test262/fdb684acf63f6274.js b/crates/swc_ecma_codegen/tests/test262/fdb684acf63f6274.js index 273640c3a64..765da1143e1 100644 --- a/crates/swc_ecma_codegen/tests/test262/fdb684acf63f6274.js +++ b/crates/swc_ecma_codegen/tests/test262/fdb684acf63f6274.js @@ -1 +1 @@ -0B10; +2;