diff --git a/crates/swc/tests/fixture/issues-6xxx/6836/1/output/index.js b/crates/swc/tests/fixture/issues-6xxx/6836/1/output/index.js index e9aa24df7a36..792468630a55 100644 --- a/crates/swc/tests/fixture/issues-6xxx/6836/1/output/index.js +++ b/crates/swc/tests/fixture/issues-6xxx/6836/1/output/index.js @@ -1 +1 @@ -console.log("\x000"); +console.log("\00"); diff --git a/crates/swc/tests/fixture/issues-8xxx/8431/input/.swcrc b/crates/swc/tests/fixture/issues-8xxx/8431/input/.swcrc new file mode 100644 index 000000000000..535f723870cd --- /dev/null +++ b/crates/swc/tests/fixture/issues-8xxx/8431/input/.swcrc @@ -0,0 +1,23 @@ +{ + "jsc": { + "parser": { + "syntax": "ecmascript", + "jsx": false + }, + "target": "es2022", + "loose": false, + "minify": { + "mangle": true, + "compress": { + "defaults": true, + "arguments": true, + "passes": 2 + } + } + }, + "module": { + "type": "es6" + }, + "minify": true, + "isModule": true +} \ No newline at end of file diff --git a/crates/swc/tests/fixture/issues-8xxx/8431/input/1.js b/crates/swc/tests/fixture/issues-8xxx/8431/input/1.js new file mode 100644 index 000000000000..3ebb4b9898a3 --- /dev/null +++ b/crates/swc/tests/fixture/issues-8xxx/8431/input/1.js @@ -0,0 +1,2 @@ +export const exampleCode_0 = '\0'; +export const exampleCode_x00 = '\x00'; \ No newline at end of file diff --git a/crates/swc/tests/fixture/issues-8xxx/8431/output/1.js b/crates/swc/tests/fixture/issues-8xxx/8431/output/1.js new file mode 100644 index 000000000000..14b163f7a0db --- /dev/null +++ b/crates/swc/tests/fixture/issues-8xxx/8431/output/1.js @@ -0,0 +1 @@ +export const exampleCode_0="\0";export const exampleCode_x00="\0"; diff --git a/crates/swc/tests/fixture/next.js/slack-1/es5/output/index.js b/crates/swc/tests/fixture/next.js/slack-1/es5/output/index.js index fce2ab1567bf..f86092a03665 100644 --- a/crates/swc/tests/fixture/next.js/slack-1/es5/output/index.js +++ b/crates/swc/tests/fixture/next.js/slack-1/es5/output/index.js @@ -1 +1 @@ -var USTAR = "ustar\x0000"; +var USTAR = "ustar\000"; diff --git a/crates/swc/tests/tsc-references/scannerStringLiteralWithContainingNullCharacter1.1.normal.js b/crates/swc/tests/tsc-references/scannerStringLiteralWithContainingNullCharacter1.1.normal.js index 5440a3182ae5..6f3b4f8f86d2 100644 --- a/crates/swc/tests/tsc-references/scannerStringLiteralWithContainingNullCharacter1.1.normal.js +++ b/crates/swc/tests/tsc-references/scannerStringLiteralWithContainingNullCharacter1.1.normal.js @@ -1,2 +1,2 @@ //// [scannerStringLiteralWithContainingNullCharacter1.ts] -" \x00 "; +" \0 "; diff --git a/crates/swc/tests/tsc-references/templateStringControlCharacterEscapes01.1.normal.js b/crates/swc/tests/tsc-references/templateStringControlCharacterEscapes01.1.normal.js index af41cd8ef240..7a164da224b8 100644 --- a/crates/swc/tests/tsc-references/templateStringControlCharacterEscapes01.1.normal.js +++ b/crates/swc/tests/tsc-references/templateStringControlCharacterEscapes01.1.normal.js @@ -1,2 +1,2 @@ //// [templateStringControlCharacterEscapes01.ts] -var x = "\x00\x00\x00 0 00 0000"; +var x = "\0\0\0 0 00 0000"; diff --git a/crates/swc/tests/tsc-references/unicodeExtendedEscapesInStrings01_ES5.1.normal.js b/crates/swc/tests/tsc-references/unicodeExtendedEscapesInStrings01_ES5.1.normal.js index 26dfcf8eff45..181335899776 100644 --- a/crates/swc/tests/tsc-references/unicodeExtendedEscapesInStrings01_ES5.1.normal.js +++ b/crates/swc/tests/tsc-references/unicodeExtendedEscapesInStrings01_ES5.1.normal.js @@ -1,2 +1,2 @@ //// [unicodeExtendedEscapesInStrings01_ES5.ts] -var x = "\x00"; +var x = "\0"; diff --git a/crates/swc/tests/tsc-references/unicodeExtendedEscapesInStrings02_ES5.1.normal.js b/crates/swc/tests/tsc-references/unicodeExtendedEscapesInStrings02_ES5.1.normal.js index 01dce2bd1a21..990b892de180 100644 --- a/crates/swc/tests/tsc-references/unicodeExtendedEscapesInStrings02_ES5.1.normal.js +++ b/crates/swc/tests/tsc-references/unicodeExtendedEscapesInStrings02_ES5.1.normal.js @@ -1,2 +1,2 @@ //// [unicodeExtendedEscapesInStrings02_ES5.ts] -var x = "\x00"; +var x = "\0"; diff --git a/crates/swc/tests/tsc-references/unicodeExtendedEscapesInStrings03_ES5.1.normal.js b/crates/swc/tests/tsc-references/unicodeExtendedEscapesInStrings03_ES5.1.normal.js index e148d06626eb..3985c0f803f6 100644 --- a/crates/swc/tests/tsc-references/unicodeExtendedEscapesInStrings03_ES5.1.normal.js +++ b/crates/swc/tests/tsc-references/unicodeExtendedEscapesInStrings03_ES5.1.normal.js @@ -1,2 +1,2 @@ //// [unicodeExtendedEscapesInStrings03_ES5.ts] -var x = "\x00"; +var x = "\0"; diff --git a/crates/swc/tests/tsc-references/unicodeExtendedEscapesInStrings04_ES5.1.normal.js b/crates/swc/tests/tsc-references/unicodeExtendedEscapesInStrings04_ES5.1.normal.js index 987562fd6d6d..8ee8ca019dc2 100644 --- a/crates/swc/tests/tsc-references/unicodeExtendedEscapesInStrings04_ES5.1.normal.js +++ b/crates/swc/tests/tsc-references/unicodeExtendedEscapesInStrings04_ES5.1.normal.js @@ -1,2 +1,2 @@ //// [unicodeExtendedEscapesInStrings04_ES5.ts] -var x = "\x00"; +var x = "\0"; diff --git a/crates/swc/tests/tsc-references/unicodeExtendedEscapesInTemplates01_ES5.1.normal.js b/crates/swc/tests/tsc-references/unicodeExtendedEscapesInTemplates01_ES5.1.normal.js index a70c1c56a1ca..b0d033788f1d 100644 --- a/crates/swc/tests/tsc-references/unicodeExtendedEscapesInTemplates01_ES5.1.normal.js +++ b/crates/swc/tests/tsc-references/unicodeExtendedEscapesInTemplates01_ES5.1.normal.js @@ -1,2 +1,2 @@ //// [unicodeExtendedEscapesInTemplates01_ES5.ts] -var x = "\x00"; +var x = "\0"; diff --git a/crates/swc/tests/tsc-references/unicodeExtendedEscapesInTemplates02_ES5.1.normal.js b/crates/swc/tests/tsc-references/unicodeExtendedEscapesInTemplates02_ES5.1.normal.js index 018f2b1cef82..67da53e21748 100644 --- a/crates/swc/tests/tsc-references/unicodeExtendedEscapesInTemplates02_ES5.1.normal.js +++ b/crates/swc/tests/tsc-references/unicodeExtendedEscapesInTemplates02_ES5.1.normal.js @@ -1,2 +1,2 @@ //// [unicodeExtendedEscapesInTemplates02_ES5.ts] -var x = "\x00"; +var x = "\0"; diff --git a/crates/swc/tests/tsc-references/unicodeExtendedEscapesInTemplates03_ES5.1.normal.js b/crates/swc/tests/tsc-references/unicodeExtendedEscapesInTemplates03_ES5.1.normal.js index 29b60440d1ce..cd573815f102 100644 --- a/crates/swc/tests/tsc-references/unicodeExtendedEscapesInTemplates03_ES5.1.normal.js +++ b/crates/swc/tests/tsc-references/unicodeExtendedEscapesInTemplates03_ES5.1.normal.js @@ -1,2 +1,2 @@ //// [unicodeExtendedEscapesInTemplates03_ES5.ts] -var x = "\x00"; +var x = "\0"; diff --git a/crates/swc/tests/tsc-references/unicodeExtendedEscapesInTemplates04_ES5.1.normal.js b/crates/swc/tests/tsc-references/unicodeExtendedEscapesInTemplates04_ES5.1.normal.js index 32cd4c1db2db..b8aaabcd3baa 100644 --- a/crates/swc/tests/tsc-references/unicodeExtendedEscapesInTemplates04_ES5.1.normal.js +++ b/crates/swc/tests/tsc-references/unicodeExtendedEscapesInTemplates04_ES5.1.normal.js @@ -1,2 +1,2 @@ //// [unicodeExtendedEscapesInTemplates04_ES5.ts] -var x = "\x00"; +var x = "\0"; diff --git a/crates/swc_ecma_codegen/src/lib.rs b/crates/swc_ecma_codegen/src/lib.rs index 7dfa870b063d..9c9984cbabf5 100644 --- a/crates/swc_ecma_codegen/src/lib.rs +++ b/crates/swc_ecma_codegen/src/lib.rs @@ -3951,7 +3951,11 @@ fn get_quoted_utf16(v: &str, ascii_only: bool, target: EsVersion) -> String { while let Some(c) = iter.next() { match c { '\x00' => { - buf.push_str("\\x00"); + if target < EsVersion::Es5 { + buf.push_str("\\x00"); + } else { + buf.push_str("\\0"); + } } '\u{0008}' => buf.push_str("\\b"), '\u{000c}' => buf.push_str("\\f"), diff --git a/crates/swc_ecma_codegen/src/tests.rs b/crates/swc_ecma_codegen/src/tests.rs index 13579a436431..99087465d686 100644 --- a/crates/swc_ecma_codegen/src/tests.rs +++ b/crates/swc_ecma_codegen/src/tests.rs @@ -101,6 +101,7 @@ pub(crate) fn assert_min(from: &str, to: &str) { assert_eq!(DebugUsingDisplay(out.trim()), DebugUsingDisplay(to),); } +#[track_caller] pub(crate) fn assert_min_target(from: &str, to: &str, target: EsVersion) { let out = parse_then_emit( from, @@ -117,6 +118,7 @@ pub(crate) fn assert_min_target(from: &str, to: &str, target: EsVersion) { } /// Clone of the regular `assert_min` function but with TypeScript syntax. +#[track_caller] pub(crate) fn assert_min_typescript(from: &str, to: &str) { let out = parse_then_emit( from, @@ -611,7 +613,7 @@ fn test_get_quoted_utf16() { es2020("abcde", "\"abcde\""); es2020( "\x00\r\n\u{85}\u{2028}\u{2029};", - "\"\\x00\\r\\n\\x85\\u2028\\u2029;\"", + "\"\\0\\r\\n\\x85\\u2028\\u2029;\"", ); es2020("\n", "\"\\n\""); @@ -619,7 +621,7 @@ fn test_get_quoted_utf16() { es2020("'string'", "\"'string'\""); - es2020("\u{0}", "\"\\x00\""); + es2020("\u{0}", "\"\\0\""); es2020("\u{1}", "\"\\x01\""); es2020("\u{1000}", "\"\\u1000\""); @@ -655,7 +657,7 @@ fn issue_1452_1() { fn issue_1619_1() { assert_min_target( "\"\\x00\" + \"\\x31\"", - "\"\\x00\"+\"1\"", + "\"\\0\"+\"1\"", EsVersion::latest(), ); } @@ -664,7 +666,7 @@ fn issue_1619_1() { fn issue_1619_2() { assert_min_target( "\"\\x00\" + \"\\x31\"", - "\"\\x00\"+\"1\"", + "\"\\0\"+\"1\"", EsVersion::latest(), ); } diff --git a/crates/swc_ecma_codegen/tests/fixture/string/output.min.js b/crates/swc_ecma_codegen/tests/fixture/string/output.min.js index 21767216b3ca..4e361f9f4b89 100644 --- a/crates/swc_ecma_codegen/tests/fixture/string/output.min.js +++ b/crates/swc_ecma_codegen/tests/fixture/string/output.min.js @@ -1,3 +1,3 @@ -import*as commonjsHelpers from"\x00commonjsHelpers.js";const string1="test";const string2="test";const string3='te"st';const string4="te'st";const string5="test\ntest\ntest";const string6=`Yet another string primitive`;const string7="This is a very long string which needs to wrap across multiple lines because otherwise my code is unreadable.";const string8="中文 español English हिन्दी العربية português বাংলা русский 日本語 ਪੰਜਾਬੀ 한국어 தமிழ்";const string9=``;const string10=`xx\`x`;const string11=`${foo+2}`;const string12=` foo ${bar+`baz ${qux}`}`;const string13=String.raw`foo`;const string14=foo`bar`;const string15=`foo +import*as commonjsHelpers from"\0commonjsHelpers.js";const string1="test";const string2="test";const string3='te"st';const string4="te'st";const string5="test\ntest\ntest";const string6=`Yet another string primitive`;const string7="This is a very long string which needs to wrap across multiple lines because otherwise my code is unreadable.";const string8="中文 español English हिन्दी العربية português বাংলা русский 日本語 ਪੰਜਾਬੀ 한국어 தமிழ்";const string9=``;const string10=`xx\`x`;const string11=`${foo+2}`;const string12=` foo ${bar+`baz ${qux}`}`;const string13=String.raw`foo`;const string14=foo`bar`;const string15=`foo bar -ↂωↂ`;const string16=`\``;const string17=`${4+4} equals 4 + 4`;const string18=`This is ${undefined}`;const string19=`This is ${NaN}`;const string20=`This is ${null}`;const string21=`This is ${Infinity}`;const string22="This is ${1/0}";const string23="This is ${1/0}";const string24="This is ${NaN}";const string25="This is ${null}";const string26=`This is ${1/0}`;const string27=`This is ${0/0}`;const string28="This is ${0/0}";const string29="This is ${0/0}";const string30=`${4**11}`;const string31=`${4**12}`;const string32=`${4**14}`;const string33="";const string34="\b";const string35="\f";const string36=" ";const string37="\v";const string38="\n";const string39="\\n";const string40="\\";const string41='\\"';const string42="'\"";const string43="\\\\";const string44="\x00";const string45="\x00!";const string46="\x001";const string47="\\0";const string48="\\0!";const string49="\x07";const string50="\x07!";const string51="\x071";const string52="\x07";const string53="\\7";const string54="\\7!";const string55="\\01";const string56="\x10";const string57="\\x10";const string58="\x1b";const string59="\\x1B";const string60="ꯍ";const string61="ꯍ";const string62="U000123AB";const string63="𒎫";const string64="\uD808\uDFAB";const string65="\uD808";const string66="\uD808X";const string67="\uDFAB";const string68="\uDFABX";const string69="€";const string70="ÿ";const string71="🍕";const string72="\uD801\uDC02\uDC03\uD804";const string73="π";const 貓="🐈";const 貓abc="🐈";const abc貓="🐈";const string74="\u2028";const string75="\u2029";const string76="\uFEFF";const string77="\x10";const string78=" ";const string79=" ";const string80="2";const string81="\x16";const string82="\x06";const string83="\x00a";const string84='"test"test"test';const string85="\"test'test'test";const string86='"test"test"test';const string87="'test'test'test";const string88="😄";const string89=new RegExp("\r").test("\r");const string90=new RegExp(" ").test(" ");const string91=new RegExp("\x1b").test("["+"\x1b"+"]");const string92=new RegExp("\\x1b").test("\x1b");const string93=new RegExp("\x1b").test("\x1b");const string94="퟿";const string95="ퟻ";const string96=sql`'#ERROR'`;const string97=" ";const string98="\ud83d\ude00";const string99="\ud83d@\ude00";const string100="a";const string101="\u2028";const string102="\uD800";const string103="\u{D800}";const string104="\uDBFF";const string105="\u{DBFF}";const string106="\uDC00";const string107="\u{DC00}";const string108="\uDFFF";const string109="\u{DFFF}";const string110="￿";const string111="￿";const string112="\ud800";const string113="\uD800";React.createElement("div",null,"this should not parse as unicode: \\u00a0");const a="֑-ۯۺ-ࣿ‏\ud802-\ud803\ud83a-\ud83bיִ-﷿ﹰ-ﻼ";const b="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ऀ-῿‎Ⰰ-\ud801\ud804-\ud839\ud83c-\udbff豈-﬜︀-﹯﻽-￿";var x="\u{D800}";var x2="\u{D800}";var x3="\u{D800}\u{D800}";const zzz="\x00a"; +ↂωↂ`;const string16=`\``;const string17=`${4+4} equals 4 + 4`;const string18=`This is ${undefined}`;const string19=`This is ${NaN}`;const string20=`This is ${null}`;const string21=`This is ${Infinity}`;const string22="This is ${1/0}";const string23="This is ${1/0}";const string24="This is ${NaN}";const string25="This is ${null}";const string26=`This is ${1/0}`;const string27=`This is ${0/0}`;const string28="This is ${0/0}";const string29="This is ${0/0}";const string30=`${4**11}`;const string31=`${4**12}`;const string32=`${4**14}`;const string33="";const string34="\b";const string35="\f";const string36=" ";const string37="\v";const string38="\n";const string39="\\n";const string40="\\";const string41='\\"';const string42="'\"";const string43="\\\\";const string44="\0";const string45="\0!";const string46="\01";const string47="\\0";const string48="\\0!";const string49="\x07";const string50="\x07!";const string51="\x071";const string52="\x07";const string53="\\7";const string54="\\7!";const string55="\\01";const string56="\x10";const string57="\\x10";const string58="\x1b";const string59="\\x1B";const string60="ꯍ";const string61="ꯍ";const string62="U000123AB";const string63="𒎫";const string64="\uD808\uDFAB";const string65="\uD808";const string66="\uD808X";const string67="\uDFAB";const string68="\uDFABX";const string69="€";const string70="ÿ";const string71="🍕";const string72="\uD801\uDC02\uDC03\uD804";const string73="π";const 貓="🐈";const 貓abc="🐈";const abc貓="🐈";const string74="\u2028";const string75="\u2029";const string76="\uFEFF";const string77="\x10";const string78=" ";const string79=" ";const string80="2";const string81="\x16";const string82="\x06";const string83="\0a";const string84='"test"test"test';const string85="\"test'test'test";const string86='"test"test"test';const string87="'test'test'test";const string88="😄";const string89=new RegExp("\r").test("\r");const string90=new RegExp(" ").test(" ");const string91=new RegExp("\x1b").test("["+"\x1b"+"]");const string92=new RegExp("\\x1b").test("\x1b");const string93=new RegExp("\x1b").test("\x1b");const string94="퟿";const string95="ퟻ";const string96=sql`'#ERROR'`;const string97=" ";const string98="\ud83d\ude00";const string99="\ud83d@\ude00";const string100="a";const string101="\u2028";const string102="\uD800";const string103="\u{D800}";const string104="\uDBFF";const string105="\u{DBFF}";const string106="\uDC00";const string107="\u{DC00}";const string108="\uDFFF";const string109="\u{DFFF}";const string110="￿";const string111="￿";const string112="\ud800";const string113="\uD800";React.createElement("div",null,"this should not parse as unicode: \\u00a0");const a="֑-ۯۺ-ࣿ‏\ud802-\ud803\ud83a-\ud83bיִ-﷿ﹰ-ﻼ";const b="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ऀ-῿‎Ⰰ-\ud801\ud804-\ud839\ud83c-\udbff豈-﬜︀-﹯﻽-￿";var x="\u{D800}";var x2="\u{D800}";var x3="\u{D800}\u{D800}";const zzz="\0a"; diff --git a/crates/swc_ecma_codegen/tests/test262-min/0b1fc7208759253b.js b/crates/swc_ecma_codegen/tests/test262-min/0b1fc7208759253b.js index da9d4480a421..8563b23ce01e 100644 --- a/crates/swc_ecma_codegen/tests/test262-min/0b1fc7208759253b.js +++ b/crates/swc_ecma_codegen/tests/test262-min/0b1fc7208759253b.js @@ -1 +1 @@ -"\x00\x01\x02\x03\x04\x05\x06\x07\b \n\v\f\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe"+a; +"\0\x01\x02\x03\x04\x05\x06\x07\b \n\v\f\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe"+a; diff --git a/crates/swc_ecma_codegen/tests/test262-min/3ae4f46daa688c58.js b/crates/swc_ecma_codegen/tests/test262-min/3ae4f46daa688c58.js index 5ec670c6e0be..25c8e047d7e3 100644 --- a/crates/swc_ecma_codegen/tests/test262-min/3ae4f46daa688c58.js +++ b/crates/swc_ecma_codegen/tests/test262-min/3ae4f46daa688c58.js @@ -1 +1 @@ -"use strict";("\x00"); +"use strict";("\0"); diff --git a/crates/swc_ecma_codegen/tests/test262-min/3d2ab39608730a47.js b/crates/swc_ecma_codegen/tests/test262-min/3d2ab39608730a47.js index 27e7385f10d0..5b22c9ac92c5 100644 --- a/crates/swc_ecma_codegen/tests/test262-min/3d2ab39608730a47.js +++ b/crates/swc_ecma_codegen/tests/test262-min/3d2ab39608730a47.js @@ -1 +1 @@ -"use strict";("\x00x"); +"use strict";("\0x"); diff --git a/crates/swc_ecma_codegen/tests/test262-min/4672c2ef688237c9.js b/crates/swc_ecma_codegen/tests/test262-min/4672c2ef688237c9.js index f56e782699bf..6e7bb0b7e5a1 100644 --- a/crates/swc_ecma_codegen/tests/test262-min/4672c2ef688237c9.js +++ b/crates/swc_ecma_codegen/tests/test262-min/4672c2ef688237c9.js @@ -1 +1 @@ -"\n\r \v\b\f\\'\"\x00"; +"\n\r \v\b\f\\'\"\0"; diff --git a/crates/swc_ecma_codegen/tests/test262-min/4fee4ac53bdfd7f7.js b/crates/swc_ecma_codegen/tests/test262-min/4fee4ac53bdfd7f7.js index 860e19dd2939..c2890cbd631e 100644 --- a/crates/swc_ecma_codegen/tests/test262-min/4fee4ac53bdfd7f7.js +++ b/crates/swc_ecma_codegen/tests/test262-min/4fee4ac53bdfd7f7.js @@ -1 +1 @@ -"Hello\x00World"; +"Hello\0World"; diff --git a/crates/swc_ecma_codegen/tests/test262-min/7c03e5eb6a9f6f1a.js b/crates/swc_ecma_codegen/tests/test262-min/7c03e5eb6a9f6f1a.js index ed457a4d783f..eaa392db17de 100644 --- a/crates/swc_ecma_codegen/tests/test262-min/7c03e5eb6a9f6f1a.js +++ b/crates/swc_ecma_codegen/tests/test262-min/7c03e5eb6a9f6f1a.js @@ -1 +1 @@ -function a(){"use strict";"\x00"} +function a(){"use strict";"\0"} diff --git a/crates/swc_ecma_codegen/tests/test262-min/84f901eb37273117.js b/crates/swc_ecma_codegen/tests/test262-min/84f901eb37273117.js index 355e2d1209cf..3c782a716d0d 100644 --- a/crates/swc_ecma_codegen/tests/test262-min/84f901eb37273117.js +++ b/crates/swc_ecma_codegen/tests/test262-min/84f901eb37273117.js @@ -1 +1 @@ -("\x00"); +("\0"); diff --git a/crates/swc_ecma_codegen/tests/test262-min/c7e5fba8bf3854cd.js b/crates/swc_ecma_codegen/tests/test262-min/c7e5fba8bf3854cd.js index 1607f38f3030..f3758da0c270 100644 --- a/crates/swc_ecma_codegen/tests/test262-min/c7e5fba8bf3854cd.js +++ b/crates/swc_ecma_codegen/tests/test262-min/c7e5fba8bf3854cd.js @@ -1 +1 @@ -(function(){"use strict";"\x00"}()); +(function(){"use strict";"\0"}()); diff --git a/crates/swc_ecma_codegen/tests/test262-min/d81d71f4121e3193.js b/crates/swc_ecma_codegen/tests/test262-min/d81d71f4121e3193.js index 355e2d1209cf..3c782a716d0d 100644 --- a/crates/swc_ecma_codegen/tests/test262-min/d81d71f4121e3193.js +++ b/crates/swc_ecma_codegen/tests/test262-min/d81d71f4121e3193.js @@ -1 +1 @@ -("\x00"); +("\0"); diff --git a/crates/swc_ecma_codegen/tests/test262/0b1fc7208759253b.js b/crates/swc_ecma_codegen/tests/test262/0b1fc7208759253b.js index 46401759987e..ae060d276c94 100644 --- a/crates/swc_ecma_codegen/tests/test262/0b1fc7208759253b.js +++ b/crates/swc_ecma_codegen/tests/test262/0b1fc7208759253b.js @@ -1 +1 @@ -"\x00\x01\x02\x03\x04\x05\x06\x07\b \n\v\f\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe" + a; +"\0\x01\x02\x03\x04\x05\x06\x07\b \n\v\f\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe" + a; diff --git a/crates/swc_ecma_codegen/tests/test262/3ae4f46daa688c58.js b/crates/swc_ecma_codegen/tests/test262/3ae4f46daa688c58.js index d133f68a7ead..5e26598bc13e 100644 --- a/crates/swc_ecma_codegen/tests/test262/3ae4f46daa688c58.js +++ b/crates/swc_ecma_codegen/tests/test262/3ae4f46daa688c58.js @@ -1,2 +1,2 @@ "use strict"; -("\x00"); +("\0"); diff --git a/crates/swc_ecma_codegen/tests/test262/3d2ab39608730a47.js b/crates/swc_ecma_codegen/tests/test262/3d2ab39608730a47.js index 3cee5ac8ca13..f172469b2eb3 100644 --- a/crates/swc_ecma_codegen/tests/test262/3d2ab39608730a47.js +++ b/crates/swc_ecma_codegen/tests/test262/3d2ab39608730a47.js @@ -1,2 +1,2 @@ "use strict"; -("\x00x"); +("\0x"); diff --git a/crates/swc_ecma_codegen/tests/test262/4672c2ef688237c9.js b/crates/swc_ecma_codegen/tests/test262/4672c2ef688237c9.js index f56e782699bf..6e7bb0b7e5a1 100644 --- a/crates/swc_ecma_codegen/tests/test262/4672c2ef688237c9.js +++ b/crates/swc_ecma_codegen/tests/test262/4672c2ef688237c9.js @@ -1 +1 @@ -"\n\r \v\b\f\\'\"\x00"; +"\n\r \v\b\f\\'\"\0"; diff --git a/crates/swc_ecma_codegen/tests/test262/4fee4ac53bdfd7f7.js b/crates/swc_ecma_codegen/tests/test262/4fee4ac53bdfd7f7.js index 860e19dd2939..c2890cbd631e 100644 --- a/crates/swc_ecma_codegen/tests/test262/4fee4ac53bdfd7f7.js +++ b/crates/swc_ecma_codegen/tests/test262/4fee4ac53bdfd7f7.js @@ -1 +1 @@ -"Hello\x00World"; +"Hello\0World"; diff --git a/crates/swc_ecma_codegen/tests/test262/7c03e5eb6a9f6f1a.js b/crates/swc_ecma_codegen/tests/test262/7c03e5eb6a9f6f1a.js index 1d78cb20a8ba..158a0311feb8 100644 --- a/crates/swc_ecma_codegen/tests/test262/7c03e5eb6a9f6f1a.js +++ b/crates/swc_ecma_codegen/tests/test262/7c03e5eb6a9f6f1a.js @@ -1,4 +1,4 @@ function a() { "use strict"; - "\x00"; + "\0"; } diff --git a/crates/swc_ecma_codegen/tests/test262/84f901eb37273117.js b/crates/swc_ecma_codegen/tests/test262/84f901eb37273117.js index 355e2d1209cf..3c782a716d0d 100644 --- a/crates/swc_ecma_codegen/tests/test262/84f901eb37273117.js +++ b/crates/swc_ecma_codegen/tests/test262/84f901eb37273117.js @@ -1 +1 @@ -("\x00"); +("\0"); diff --git a/crates/swc_ecma_codegen/tests/test262/c7e5fba8bf3854cd.js b/crates/swc_ecma_codegen/tests/test262/c7e5fba8bf3854cd.js index 1bb241320408..ace2e090dc7f 100644 --- a/crates/swc_ecma_codegen/tests/test262/c7e5fba8bf3854cd.js +++ b/crates/swc_ecma_codegen/tests/test262/c7e5fba8bf3854cd.js @@ -1,4 +1,4 @@ (function() { "use strict"; - "\x00"; + "\0"; }()); diff --git a/crates/swc_ecma_codegen/tests/test262/d81d71f4121e3193.js b/crates/swc_ecma_codegen/tests/test262/d81d71f4121e3193.js index 355e2d1209cf..3c782a716d0d 100644 --- a/crates/swc_ecma_codegen/tests/test262/d81d71f4121e3193.js +++ b/crates/swc_ecma_codegen/tests/test262/d81d71f4121e3193.js @@ -1 +1 @@ -("\x00"); +("\0"); diff --git a/crates/swc_ecma_minifier/tests/fixture/next/react-pdf-renderer/output.js b/crates/swc_ecma_minifier/tests/fixture/next/react-pdf-renderer/output.js index ed3871d061f9..e0903e681bfd 100644 --- a/crates/swc_ecma_minifier/tests/fixture/next/react-pdf-renderer/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/next/react-pdf-renderer/output.js @@ -2097,7 +2097,7 @@ } }) }) : t.push({ - string: s.replace(i, "\x00"), + string: s.replace(i, "\0"), attributes: n.attributes }), o = a + u.length; } diff --git a/crates/swc_ecma_minifier/tests/terser/compress/object/property_with_unprintable/output.mangleOnly.js b/crates/swc_ecma_minifier/tests/terser/compress/object/property_with_unprintable/output.mangleOnly.js index 021e140b5599..d92325c9fe39 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/object/property_with_unprintable/output.mangleOnly.js +++ b/crates/swc_ecma_minifier/tests/terser/compress/object/property_with_unprintable/output.mangleOnly.js @@ -1,4 +1,4 @@ -var x = { +var r = { "\0": "foo", get "\0" () { return "bar"; @@ -10,12 +10,12 @@ var x = { return "foobar"; } }; -class r { +class e { get "\0"() { return "bar"; } - set "\0"(x) { - save(x); + set "\0"(r) { + save(r); } *"\0"() { return "foobar"; diff --git a/crates/swc_ecma_minifier/tests/terser/compress/object/property_with_unprintable_ascii_only/output.mangleOnly.js b/crates/swc_ecma_minifier/tests/terser/compress/object/property_with_unprintable_ascii_only/output.mangleOnly.js index 6610a9fb895e..8c9c70e43df7 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/object/property_with_unprintable_ascii_only/output.mangleOnly.js +++ b/crates/swc_ecma_minifier/tests/terser/compress/object/property_with_unprintable_ascii_only/output.mangleOnly.js @@ -1,4 +1,4 @@ -var x = { +var r = { "\0\x01": "foo", get "\0\x01" () { return "bar"; @@ -10,12 +10,12 @@ var x = { return "foobar"; } }; -class r { +class e { get "\0\x01"() { return "bar"; } - set "\0\x01"(x) { - save(x); + set "\0\x01"(r) { + save(r); } *"\0\x01"() { return "foobar"; diff --git a/crates/swc_ecma_minifier/tests/terser/compress/string_literal/octal_escape_sequence/output.mangleOnly.js b/crates/swc_ecma_minifier/tests/terser/compress/string_literal/octal_escape_sequence/output.mangleOnly.js index e3f51be4806b..8bfe91573c7a 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/string_literal/octal_escape_sequence/output.mangleOnly.js +++ b/crates/swc_ecma_minifier/tests/terser/compress/string_literal/octal_escape_sequence/output.mangleOnly.js @@ -1,2 +1,2 @@ -var x = "\0\08?\0?Àÿ"; -var a = " 080\x000À0"; +var a = "\0\08?\0?Àÿ"; +var r = " 080\x000À0"; diff --git a/crates/swc_ecma_transforms_optimization/tests/__swc_snapshots__/tests/simplify.rs/issue_1619_1.js b/crates/swc_ecma_transforms_optimization/tests/__swc_snapshots__/tests/simplify.rs/issue_1619_1.js index d656adc20371..10398c41ede0 100644 --- a/crates/swc_ecma_transforms_optimization/tests/__swc_snapshots__/tests/simplify.rs/issue_1619_1.js +++ b/crates/swc_ecma_transforms_optimization/tests/__swc_snapshots__/tests/simplify.rs/issue_1619_1.js @@ -1,2 +1,2 @@ "use strict"; -console.log("\x001"); +console.log("\01");