Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix(es/ast): Pin version of unicodes #8941

Merged
merged 13 commits into from
May 10, 2024
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ resolver = "2"
tracing-subscriber = "0.3.18"
typed-arena = "2.0.1"
unicode-id = "0.3"
unicode-id-start = "1.1.2"
unicode-id-start = "=1.0.4"
unicode-width = "0.1.4"
url = "2.4.0"
vergen = { version = "8.0.0", default-features = false }
Expand Down
64 changes: 64 additions & 0 deletions crates/swc/tests/fixture/issues-8xxx/8940/input/.swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"jsc": {
"parser": {
"syntax": "typescript",
"tsx": false
},
"target": "es5",
"loose": false,
"minify": {
"compress": {
"arguments": false,
"arrows": true,
"booleans": true,
"booleans_as_integers": false,
"collapse_vars": true,
"comparisons": true,
"computed_props": true,
"conditionals": true,
"dead_code": true,
"directives": true,
"drop_console": false,
"drop_debugger": true,
"evaluate": true,
"expression": false,
"hoist_funs": false,
"hoist_props": true,
"hoist_vars": false,
"if_return": true,
"join_vars": true,
"keep_classnames": false,
"keep_fargs": true,
"keep_fnames": false,
"keep_infinity": false,
"loops": true,
"negate_iife": true,
"properties": true,
"reduce_funcs": false,
"reduce_vars": false,
"side_effects": true,
"switches": true,
"typeofs": true,
"unsafe": false,
"unsafe_arrows": false,
"unsafe_comps": false,
"unsafe_Function": false,
"unsafe_math": false,
"unsafe_symbols": false,
"unsafe_methods": false,
"unsafe_proto": false,
"unsafe_regexp": false,
"unsafe_undefined": false,
"unused": true,
"const_to_let": true,
"pristine_globals": true
},
"mangle": false
}
},
"module": {
"type": "es6"
},
"minify": false,
"isModule": true
}
7 changes: 7 additions & 0 deletions crates/swc/tests/fixture/issues-8xxx/8940/input/1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
console.log({
"あ": 1,
"あ・あ": 1,
"・あ": 1,
"・": 1,
"あ・": 1,
})
7 changes: 7 additions & 0 deletions crates/swc/tests/fixture/issues-8xxx/8940/output/1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
console.log({
あ: 1,
"あ・あ": 1,
"・あ": 1,
"・": 1,
"あ・": 1
});
5 changes: 5 additions & 0 deletions crates/swc_ecma_codegen/tests/sourcemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,11 @@ static IGNORED_PASS_TESTS: &[&str] = &[
"bc302492d441d561.js",
"be2fd5888f434cbd.js",
"f3260491590325af.js",
// Unicode 14 vs 15
"046a0bb70d03d0cc.js",
"08a39e4289b0c3f3.js",
"300a638d978d0f2c.js",
"44f31660bd715f05.js",
];

#[testing::fixture("../swc_ecma_parser/tests/test262-parser/pass/*.js")]
Expand Down
5 changes: 5 additions & 0 deletions crates/swc_ecma_codegen/tests/test262.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ const IGNORED_PASS_TESTS: &[&str] = &[
"59ae0289778b80cd.js",
"a4d62a651f69d815.js",
"c06df922631aeabc.js",
// Unicode 14 vs 15
"046a0bb70d03d0cc.js",
"08a39e4289b0c3f3.js",
"300a638d978d0f2c.js",
"44f31660bd715f05.js",
];

#[testing::fixture("../swc_ecma_parser/tests/test262-parser/pass/*.js")]
Expand Down
7 changes: 2 additions & 5 deletions crates/swc_ecma_minifier/src/compress/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,14 +403,11 @@ pub(crate) fn is_primitive<'a>(expr_ctx: &ExprCtx, e: &'a Expr) -> Option<&'a Ex
}

pub(crate) fn is_valid_identifier(s: &str, ascii_only: bool) -> bool {
if ascii_only {
if s.chars().any(|c| !c.is_ascii()) {
return false;
}
if ascii_only && !s.is_ascii() {
return false;
}
s.starts_with(Ident::is_valid_start)
&& s.chars().skip(1).all(Ident::is_valid_continue)
&& !s.contains('𝒶')
&& !s.is_reserved()
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
console.log({ "𝒶": "foo" });
console.log({
𝒶: "foo"
});
5 changes: 5 additions & 0 deletions crates/swc_ecma_parser/tests/test262.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ const IGNORED_PASS_TESTS: &[&str] = &[
// Wrong test - strict mode
"8f8bfb27569ac008.js",
"ce569e89a005c02a.js",
// Unicode 14 vs 15
"046a0bb70d03d0cc.js",
"08a39e4289b0c3f3.js",
"300a638d978d0f2c.js",
"44f31660bd715f05.js",
];

fn add_test<F: FnOnce() -> Result<(), String> + Send + 'static>(
Expand Down
5 changes: 5 additions & 0 deletions crates/swc_ecma_transforms_base/tests/fixer_test262.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ const IGNORED_PASS_TESTS: &[&str] = &[
"59ae0289778b80cd.js",
"a4d62a651f69d815.js",
"c06df922631aeabc.js",
// Unicode 14 vs 15
"046a0bb70d03d0cc.js",
"08a39e4289b0c3f3.js",
"300a638d978d0f2c.js",
"44f31660bd715f05.js",
];

fn add_test<F: FnOnce() -> Result<(), String> + Send + 'static>(
Expand Down
Loading