Skip to content

Commit

Permalink
fix(es/ast): Fix handling of reserved words (#1891)
Browse files Browse the repository at this point in the history
  • Loading branch information
Austaras authored Jul 4, 2021
1 parent 14cee03 commit 7634106
Show file tree
Hide file tree
Showing 32 changed files with 234 additions and 211 deletions.
22 changes: 11 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc"
repository = "https://github.com/swc-project/swc.git"
version = "0.26.0"
version = "0.27.0"

[lib]
name = "swc"
Expand All @@ -30,24 +30,24 @@ serde = {version = "1", features = ["derive"]}
serde_json = "1"
sourcemap = "6"
swc_atoms = {version = "0.2", path = "./atoms"}
swc_bundler = {version = "0.44.0", path = "./bundler"}
swc_bundler = {version = "0.45.0", path = "./bundler"}
swc_common = {version = "0.10.16", path = "./common", features = ["sourcemap", "concurrent"]}
swc_ecma_ast = {version = "0.47.0", path = "./ecmascript/ast"}
swc_ecma_codegen = {version = "0.60.0", path = "./ecmascript/codegen"}
swc_ecma_ext_transforms = {version = "0.19.0", path = "./ecmascript/ext-transforms"}
swc_ecma_loader = {version = "0.9.0", path = "./ecmascript/loader", features = ["lru", "node", "tsc"]}
swc_ecma_parser = {version = "0.61.0", path = "./ecmascript/parser"}
swc_ecma_preset_env = {version = "0.27.0", path = "./ecmascript/preset-env"}
swc_ecma_transforms = {version = "0.57.0", path = "./ecmascript/transforms", features = [
swc_ecma_ast = {version = "0.48.0", path = "./ecmascript/ast"}
swc_ecma_codegen = {version = "0.61.0", path = "./ecmascript/codegen"}
swc_ecma_ext_transforms = {version = "0.20.0", path = "./ecmascript/ext-transforms"}
swc_ecma_loader = {version = "0.10.0", path = "./ecmascript/loader", features = ["lru", "node", "tsc"]}
swc_ecma_parser = {version = "0.62.0", path = "./ecmascript/parser"}
swc_ecma_preset_env = {version = "0.28.0", path = "./ecmascript/preset-env"}
swc_ecma_transforms = {version = "0.58.0", path = "./ecmascript/transforms", features = [
"compat",
"module",
"optimization",
"proposal",
"react",
"typescript",
]}
swc_ecma_utils = {version = "0.38.0", path = "./ecmascript/utils"}
swc_ecma_visit = {version = "0.33.0", path = "./ecmascript/visit"}
swc_ecma_utils = {version = "0.39.0", path = "./ecmascript/utils"}
swc_ecma_visit = {version = "0.34.0", path = "./ecmascript/visit"}
swc_node_base = {version = "0.1.0", path = "./node/base"}
swc_visit = {version = "0.2.3", path = "./visit"}

Expand Down
18 changes: 9 additions & 9 deletions bundler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ include = ["Cargo.toml", "build.rs", "src/**/*.rs", "src/**/*.js"]
license = "Apache-2.0/MIT"
name = "swc_bundler"
repository = "https://github.com/swc-project/swc.git"
version = "0.44.1"
version = "0.45.0"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
Expand All @@ -33,20 +33,20 @@ relative-path = "1.2"
retain_mut = "0.1.2"
swc_atoms = {version = "0.2.4", path = "../atoms"}
swc_common = {version = "0.10.16", path = "../common"}
swc_ecma_ast = {version = "0.47.0", path = "../ecmascript/ast"}
swc_ecma_codegen = {version = "0.60.0", path = "../ecmascript/codegen"}
swc_ecma_loader = {version = "0.9.0", path = "../ecmascript/loader"}
swc_ecma_parser = {version = "0.61.0", path = "../ecmascript/parser"}
swc_ecma_transforms = {version = "0.57.0", path = "../ecmascript/transforms", features = ["optimization"]}
swc_ecma_utils = {version = "0.38.0", path = "../ecmascript/utils"}
swc_ecma_visit = {version = "0.33.0", path = "../ecmascript/visit"}
swc_ecma_ast = {version = "0.48.0", path = "../ecmascript/ast"}
swc_ecma_codegen = {version = "0.61.0", path = "../ecmascript/codegen"}
swc_ecma_loader = {version = "0.10.0", path = "../ecmascript/loader"}
swc_ecma_parser = {version = "0.62.0", path = "../ecmascript/parser"}
swc_ecma_transforms = {version = "0.58.0", path = "../ecmascript/transforms", features = ["optimization"]}
swc_ecma_utils = {version = "0.39.0", path = "../ecmascript/utils"}
swc_ecma_visit = {version = "0.34.0", path = "../ecmascript/visit"}

[dev-dependencies]
hex = "0.4"
ntest = "0.7.2"
reqwest = {version = "0.10.8", features = ["blocking"]}
sha-1 = "0.9"
swc_ecma_transforms = {version = "0.57.0", path = "../ecmascript/transforms", features = ["react", "typescript"]}
swc_ecma_transforms = {version = "0.58.0", path = "../ecmascript/transforms", features = ["react", "typescript"]}
tempfile = "3.1.0"
testing = {version = "0.10.5", path = "../testing"}
url = "2.1.1"
Expand Down
2 changes: 1 addition & 1 deletion bundler/src/bundler/keywords.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl KeywordRenamer {
return None;
}

if !id.is_reserved_for_es3() {
if !(id.is_reserved() || id.is_reserved_in_strict_mode(true) || id.is_reserved_in_es3()) {
return None;
}

Expand Down
18 changes: 9 additions & 9 deletions ecmascript/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_ecmascript"
repository = "https://github.com/swc-project/swc.git"
version = "0.44.0"
version = "0.45.0"

[package.metadata.docs.rs]
all-features = true
Expand All @@ -28,13 +28,13 @@ react = ["swc_ecma_transforms/react"]
typescript = ["swc_ecma_transforms/typescript"]

[dependencies]
swc_ecma_ast = {version = "0.47.0", path = "./ast"}
swc_ecma_codegen = {version = "0.60.0", path = "./codegen", optional = true}
swc_ecma_dep_graph = {version = "0.29.0", path = "./dep-graph", optional = true}
swc_ecma_minifier = {version = "0.10.0", path = "./minifier", optional = true}
swc_ecma_parser = {version = "0.61.0", path = "./parser", optional = true}
swc_ecma_transforms = {version = "0.57.0", path = "./transforms", optional = true}
swc_ecma_utils = {version = "0.38.0", path = "./utils", optional = true}
swc_ecma_visit = {version = "0.33.0", path = "./visit", optional = true}
swc_ecma_ast = {version = "0.48.0", path = "./ast"}
swc_ecma_codegen = {version = "0.61.0", path = "./codegen", optional = true}
swc_ecma_dep_graph = {version = "0.30.0", path = "./dep-graph", optional = true}
swc_ecma_minifier = {version = "0.11.0", path = "./minifier", optional = true}
swc_ecma_parser = {version = "0.62.0", path = "./parser", optional = true}
swc_ecma_transforms = {version = "0.58.0", path = "./transforms", optional = true}
swc_ecma_utils = {version = "0.39.0", path = "./utils", optional = true}
swc_ecma_visit = {version = "0.34.0", path = "./visit", optional = true}

[dev-dependencies]
2 changes: 1 addition & 1 deletion ecmascript/ast/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_ecma_ast"
repository = "https://github.com/swc-project/swc.git"
version = "0.47.0"
version = "0.48.0"

[features]
default = []
Expand Down
56 changes: 24 additions & 32 deletions ecmascript/ast/src/ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,93 +82,85 @@ impl Ident {
}

pub trait IdentExt: AsRef<str> {
fn is_reserved_for_es3(&self) -> bool {
fn is_reserved(&self) -> bool {
[
"abstract",
"boolean",
"break",
"byte",
"case",
"catch",
"char",
"class",
"const",
"continue",
"debugger",
"default",
"delete",
"do",
"double",
"else",
"enum",
"export",
"extends",
"false",
"final",
"finally",
"float",
"for",
"function",
"goto",
"if",
"implements",
"import",
"in",
"instanceof",
"int",
"interface",
"long",
"native",
"new",
"null",
"package",
"private",
"protected",
"public",
"return",
"short",
"static",
"super",
"switch",
"synchronized",
"this",
"throw",
"throws",
"transient",
"true",
"try",
"typeof",
"var",
"void",
"volatile",
"while",
"with",
]
.contains(&self.as_ref())
}

fn is_reserved_only_for_es3(&self) -> bool {
fn is_reserved_in_strict_mode(&self, is_module: bool) -> bool {
if is_module && self.as_ref() == "await" {
return true;
}
[
"implements",
"interface",
"let",
"package",
"private",
"protected",
"public",
"static",
"yield",
]
.contains(&self.as_ref())
}

fn is_reserved_in_strict_bind(&self) -> bool {
["eval", "arguments"].contains(&self.as_ref())
}

fn is_reserved_in_es3(&self) -> bool {
[
"abstract",
"boolean",
"byte",
"char",
"double",
"enum",
"final",
"float",
"goto",
"implements",
"int",
"interface",
"long",
"native",
"package",
"private",
"protected",
"public",
"short",
"static",
"synchronized",
"throws",
"transient",
Expand Down
6 changes: 3 additions & 3 deletions ecmascript/codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ include = ["Cargo.toml", "src/**/*.rs"]
license = "Apache-2.0/MIT"
name = "swc_ecma_codegen"
repository = "https://github.com/swc-project/swc.git"
version = "0.60.1"
version = "0.61.0"

[dependencies]
bitflags = "1"
num-bigint = {version = "0.2", features = ["serde"]}
sourcemap = "6"
swc_atoms = {version = "0.2", path = "../../atoms"}
swc_common = {version = "0.10.21", path = "../../common"}
swc_ecma_ast = {version = "0.47.0", path = "../ast"}
swc_ecma_ast = {version = "0.48.0", path = "../ast"}
swc_ecma_codegen_macros = {version = "0.5.2", path = "./macros"}
swc_ecma_parser = {version = "0.61.0", path = "../parser"}
swc_ecma_parser = {version = "0.62.0", path = "../parser"}

[dev-dependencies]
swc_common = {version = "0.10.16", path = "../../common", features = ["sourcemap"]}
Expand Down
8 changes: 4 additions & 4 deletions ecmascript/dep-graph/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_ecma_dep_graph"
repository = "https://github.com/swc-project/swc.git"
version = "0.29.0"
version = "0.30.0"

[dependencies]
swc_atoms = {version = "0.2", path = "../../atoms"}
swc_common = {version = "0.10.16", path = "../../common"}
swc_ecma_ast = {version = "0.47.0", path = "../ast"}
swc_ecma_visit = {version = "0.33.0", path = "../visit"}
swc_ecma_ast = {version = "0.48.0", path = "../ast"}
swc_ecma_visit = {version = "0.34.0", path = "../visit"}

[dev-dependencies]
swc_ecma_parser = {version = "0.61.0", path = "../parser"}
swc_ecma_parser = {version = "0.62.0", path = "../parser"}
testing = {version = "0.10.5", path = "../../testing"}
10 changes: 5 additions & 5 deletions ecmascript/ext-transforms/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ documentation = "https://rustdoc.swc.rs/swc_ecma_ext_transforms/"
edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_ecma_ext_transforms"
version = "0.19.0"
version = "0.20.0"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
phf = {version = "0.8.0", features = ["macros"]}
swc_atoms = {version = "0.2", path = "../../atoms"}
swc_common = {version = "0.10.16", path = "../../common"}
swc_ecma_ast = {version = "0.47.0", path = "../ast"}
swc_ecma_parser = {version = "0.61.0", path = "../parser"}
swc_ecma_utils = {version = "0.38.0", path = "../utils"}
swc_ecma_visit = {version = "0.33.0", path = "../visit"}
swc_ecma_ast = {version = "0.48.0", path = "../ast"}
swc_ecma_parser = {version = "0.62.0", path = "../parser"}
swc_ecma_utils = {version = "0.39.0", path = "../utils"}
swc_ecma_visit = {version = "0.34.0", path = "../visit"}
6 changes: 3 additions & 3 deletions ecmascript/jsdoc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ documentation = "https://rustdoc.swc.rs/jsdoc/"
edition = "2018"
license = "Apache-2.0/MIT"
name = "jsdoc"
version = "0.29.0"
version = "0.30.0"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand All @@ -18,7 +18,7 @@ swc_common = {version = "0.10.16", path = "../../common"}
[dev-dependencies]
anyhow = "1"
dashmap = "4.0.2"
swc_ecma_ast = {version = "0.47.0", path = "../ast"}
swc_ecma_parser = {version = "0.61.0", path = "../parser"}
swc_ecma_ast = {version = "0.48.0", path = "../ast"}
swc_ecma_parser = {version = "0.62.0", path = "../parser"}
testing = {version = "0.10.5", path = "../../testing"}
walkdir = "2"
6 changes: 3 additions & 3 deletions ecmascript/loader/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_ecma_loader"
repository = "https://github.com/swc-project/swc.git"
version = "0.9.1"
version = "0.10.0"

[package.metadata.docs.rs]
all-features = true
Expand All @@ -29,8 +29,8 @@ serde = {version = "1.0.126", optional = true}
serde_json = {version = "1.0.64", optional = true}
swc_atoms = {version = "0.2.3", path = "../../atoms"}
swc_common = {version = "0.10.16", path = "../../common"}
swc_ecma_ast = {version = "0.47.0", path = "../ast"}
swc_ecma_visit = {version = "0.33.0", path = "../visit"}
swc_ecma_ast = {version = "0.48.0", path = "../ast"}
swc_ecma_visit = {version = "0.34.0", path = "../visit"}

[dev-dependencies]
testing = {version = "0.10.5", path = "../../testing"}
Expand Down
16 changes: 8 additions & 8 deletions ecmascript/minifier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ include = ["Cargo.toml", "src/**/*.rs", "src/lists/*.json"]
license = "Apache-2.0/MIT"
name = "swc_ecma_minifier"
repository = "https://github.com/swc-project/swc.git"
version = "0.10.1"
version = "0.11.0"

[features]
debug = []
Expand All @@ -24,13 +24,13 @@ serde_json = "1.0.61"
serde_regex = "1.1.0"
swc_atoms = {version = "0.2", path = "../../atoms"}
swc_common = {version = "0.10.8", path = "../../common"}
swc_ecma_ast = {version = "0.47.0", path = "../ast"}
swc_ecma_codegen = {version = "0.60.0", path = "../codegen"}
swc_ecma_parser = {version = "0.61.0", path = "../parser"}
swc_ecma_transforms = {version = "0.57.0", path = "../transforms/", features = ["optimization"]}
swc_ecma_transforms_base = {version = "0.20.0", path = "../transforms/base"}
swc_ecma_utils = {version = "0.38.0", path = "../utils"}
swc_ecma_visit = {version = "0.33.0", path = "../visit"}
swc_ecma_ast = {version = "0.48.0", path = "../ast"}
swc_ecma_codegen = {version = "0.61.0", path = "../codegen"}
swc_ecma_parser = {version = "0.62.0", path = "../parser"}
swc_ecma_transforms = {version = "0.58.0", path = "../transforms/", features = ["optimization"]}
swc_ecma_transforms_base = {version = "0.21.0", path = "../transforms/base"}
swc_ecma_utils = {version = "0.39.0", path = "../utils"}
swc_ecma_visit = {version = "0.34.0", path = "../visit"}

[dev-dependencies]
ansi_term = "0.12.1"
Expand Down
6 changes: 3 additions & 3 deletions ecmascript/parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ include = ["Cargo.toml", "src/**/*.rs", "examples/**/*.rs"]
license = "Apache-2.0/MIT"
name = "swc_ecma_parser"
repository = "https://github.com/swc-project/swc.git"
version = "0.61.3"
version = "0.62.0"

[features]
default = []
Expand All @@ -23,8 +23,8 @@ serde = {version = "1", features = ["derive"]}
smallvec = "1"
swc_atoms = {version = "0.2.3", path = "../../atoms"}
swc_common = {version = "0.10.16", path = "../../common"}
swc_ecma_ast = {version = "0.47.0", path = "../ast"}
swc_ecma_visit = {version = "0.33.0", path = "../visit"}
swc_ecma_ast = {version = "0.48.0", path = "../ast"}
swc_ecma_visit = {version = "0.34.0", path = "../visit"}
unicode-xid = "0.2"

[dev-dependencies]
Expand Down
Loading

0 comments on commit 7634106

Please sign in to comment.