diff --git a/.github/workflows/cargo.yml b/.github/workflows/cargo.yml index b5823351cde..f0ab16b3fa0 100644 --- a/.github/workflows/cargo.yml +++ b/.github/workflows/cargo.yml @@ -13,7 +13,6 @@ on: [push, pull_request] # - 'trying' env: - RUST_MIN_STACK: 16777216 CARGO_INCREMENTAL: 0 CI: "1" diff --git a/.travis.yml b/.travis.yml index 369a4ffe913..11d694d71ec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,7 +28,6 @@ before_install: - sed -i 's/git@github.com:/https:\/\/github.com\//' .gitmodules - git submodule update --init --recursive - install: - rm -rf ~/.nvm - git clone https://github.com/creationix/nvm.git ~/.nvm @@ -66,7 +65,6 @@ notifications: env: global: - CASHER_TIME_OUT=600 - - RUST_MIN_STACK=16777216 - CARGO_INCREMENTAL=0 - RUSTFLAGS="--cfg procmacro2_semver_exempt" - secure: Z4RSNlpg/12Qx2fIjS+7TToYxPJQgK70X7u9A5lJiCIa0JfzWCxr1ZEKXfAVLG9o4nQok+nWOZa+vxR1IgyUVnf6oSanjjWl1pSRbvccxMS799NvHmGzIAiqSKAlxiSJuxf7MQbs1XBuI3XahsWLfXGPo7vPT6sKe4AAf9gT6igJr61D5hpHkVIXK7P6rnrWQALQYplyaox0NlU9UlqSXXBjdJfp3138rl7FIeYRsMMow44unBNPvs+mhVP8PWpeFWeop0jxbNbTHwnJUbCm4ZWrvqnJ/m70IMlBMN1AskLmz4KeXOhPx+XR9VtdWBX4q8lJ7s9J0hMBxrEnxgiYVBPMlLoEX+wW3zwZ5F+DQs7uLpRHYRUpxpi/7ZuQjp+uT3mN9PMMSvbHwHLH2r/CC9olKYWySXIsGsGVyyMnZeUwvgzwxiYLoeCWe4zZY99zc7jvGKbSmk0RtPu6hApPwL5A6novXbXL2QsXzqqeWpgMLmZyb7KYhM5IGIAB1oPQIqI++Re9Z+/ea/DRSUJOsA96yRQ+vVbiuClrVgDhaAaJOGYCtR1XZ5N2zRb9+Spu/ECtfisLOb9Xs1584DyRbqG69nRdjuscjYOTFZUlOoOeFvuADY65Jt0kF6u7g8NIDkJ1ROb3heKQtY/bAQUrBNUJydOQnn5tBwn8Z618+Ac= diff --git a/common/Cargo.toml b/common/Cargo.toml index 7d7f82fe34a..49acfba2220 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "swc_common" -version = "0.5.11" +version = "0.5.12" authors = ["강동윤 "] license = "Apache-2.0/MIT" repository = "https://github.com/swc-project/swc.git" diff --git a/common/src/errors/diagnostic_builder.rs b/common/src/errors/diagnostic_builder.rs index 42e8f84684f..da56632d45f 100644 --- a/common/src/errors/diagnostic_builder.rs +++ b/common/src/errors/diagnostic_builder.rs @@ -27,7 +27,7 @@ use std::{ #[derive(Clone)] pub struct DiagnosticBuilder<'a> { pub handler: &'a Handler, - diagnostic: Diagnostic, + diagnostic: Box, allow_suggestions: bool, } @@ -115,7 +115,7 @@ impl<'a> DiagnosticBuilder<'a> { // Logging here is useful to help track down where in logs an error was // actually emitted. debug!("buffer: diagnostic={:?}", diagnostic); - buffered_diagnostics.push(diagnostic); + buffered_diagnostics.push(*diagnostic); } /// Convenience function for internal use, clients should use one of the @@ -143,7 +143,7 @@ impl<'a> DiagnosticBuilder<'a> { /// locally in whichever way makes the most sense. pub fn delay_as_bug(&mut self) { self.level = Level::Bug; - self.handler.delay_as_bug(self.diagnostic.clone()); + self.handler.delay_as_bug(*self.diagnostic.clone()); self.cancel(); } @@ -304,10 +304,11 @@ impl<'a> DiagnosticBuilder<'a> { /// Creates a new `DiagnosticBuilder` with an already constructed /// diagnostic. + #[inline(always)] // box pub fn new_diagnostic(handler: &'a Handler, diagnostic: Diagnostic) -> DiagnosticBuilder<'a> { DiagnosticBuilder { handler, - diagnostic, + diagnostic: Box::new(diagnostic), allow_suggestions: true, } } diff --git a/ecmascript/codegen/tests/references/6b5e7e125097d439.js b/ecmascript/codegen/tests/references/6b5e7e125097d439.js deleted file mode 100644 index 1d05f1721b0..00000000000 --- a/ecmascript/codegen/tests/references/6b5e7e125097d439.js +++ /dev/null @@ -1 +0,0 @@ -a.a = 1; diff --git a/ecmascript/codegen/tests/references/714be6d28082eaa7.js b/ecmascript/codegen/tests/references/714be6d28082eaa7.js deleted file mode 100644 index 5040b776d42..00000000000 --- a/ecmascript/codegen/tests/references/714be6d28082eaa7.js +++ /dev/null @@ -1 +0,0 @@ -a = 1; diff --git a/ecmascript/codegen/tests/references/882910de7dd1aef9.js b/ecmascript/codegen/tests/references/882910de7dd1aef9.js deleted file mode 100644 index 3804c15a76f..00000000000 --- a/ecmascript/codegen/tests/references/882910de7dd1aef9.js +++ /dev/null @@ -1 +0,0 @@ -((((((((((((((((((((((((((((((((((((((((a)))))))))))))))))))))))))))))))))))))))); diff --git a/ecmascript/codegen/tests/references/dd3c63403db5c06e.js b/ecmascript/codegen/tests/references/dd3c63403db5c06e.js deleted file mode 100644 index 97777256f98..00000000000 --- a/ecmascript/codegen/tests/references/dd3c63403db5c06e.js +++ /dev/null @@ -1 +0,0 @@ -((((((((((((((((((((((((((((((((((((((((((((((((((1)))))))))))))))))))))))))))))))))))))))))))))))))); diff --git a/ecmascript/codegen/tests/test262.rs b/ecmascript/codegen/tests/test262.rs index e6c6255c463..29bf15b70af 100644 --- a/ecmascript/codegen/tests/test262.rs +++ b/ecmascript/codegen/tests/test262.rs @@ -24,6 +24,11 @@ const IGNORED_PASS_TESTS: &[&str] = &[ "431ecef8c85d4d24.js", "8386fbff927a9e0e.js", "5654d4106d7025c2.js", + // Stack size (Stupid parens) + "6b5e7e125097d439.js", + "714be6d28082eaa7.js", + "882910de7dd1aef9.js", + "dd3c63403db5c06e.js", // Wrong tests (variable name or value is different) "0339fa95c78c11bd.js", "0426f15dac46e92d.js", diff --git a/ecmascript/parser/tests/test262.rs b/ecmascript/parser/tests/test262.rs index 83f76a06df8..60d48d43b61 100644 --- a/ecmascript/parser/tests/test262.rs +++ b/ecmascript/parser/tests/test262.rs @@ -24,6 +24,11 @@ const IGNORED_PASS_TESTS: &[&str] = &[ "431ecef8c85d4d24.js", "8386fbff927a9e0e.js", "5654d4106d7025c2.js", + // Stack size (Stupid parens) + "6b5e7e125097d439.js", + "714be6d28082eaa7.js", + "882910de7dd1aef9.js", + "dd3c63403db5c06e.js", // Static constructor "dcc5609dcc043200.js", "88d42455ac933ef5.js", diff --git a/ecmascript/parser/tests/typescript/stack-size/input.ts b/ecmascript/parser/tests/typescript/stack-size/input.ts new file mode 100644 index 00000000000..c0caaf28c28 --- /dev/null +++ b/ecmascript/parser/tests/typescript/stack-size/input.ts @@ -0,0 +1,25 @@ +module.exports = function test() { + if (true) { + if (true) { + while (test) { + if (test) { + if (test) { + if (test) { + if (test) { + while (test) { + if (test) { + if (asdf) { + if (asdf) { + test += ' || ' + (test) + ' === null || ' + (test) + ' === \'\' '; + } + } + } + } + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/ecmascript/parser/tests/typescript/stack-size/input.ts.json b/ecmascript/parser/tests/typescript/stack-size/input.ts.json new file mode 100644 index 00000000000..2817f4ce861 --- /dev/null +++ b/ecmascript/parser/tests/typescript/stack-size/input.ts.json @@ -0,0 +1,550 @@ +{ + "type": "Module", + "span": { + "start": 0, + "end": 839, + "ctxt": 0 + }, + "body": [ + { + "type": "ExpressionStatement", + "span": { + "start": 0, + "end": 839, + "ctxt": 0 + }, + "expression": { + "type": "AssignmentExpression", + "span": { + "start": 0, + "end": 839, + "ctxt": 0 + }, + "operator": "=", + "left": { + "type": "MemberExpression", + "span": { + "start": 0, + "end": 14, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 0, + "end": 6, + "ctxt": 0 + }, + "value": "module", + "typeAnnotation": null, + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 7, + "end": 14, + "ctxt": 0 + }, + "value": "exports", + "typeAnnotation": null, + "optional": false + }, + "computed": false + }, + "right": { + "type": "FunctionExpression", + "identifier": { + "type": "Identifier", + "span": { + "start": 26, + "end": 30, + "ctxt": 0 + }, + "value": "test", + "typeAnnotation": null, + "optional": false + }, + "params": [], + "decorators": [], + "span": { + "start": 17, + "end": 839, + "ctxt": 0 + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 33, + "end": 839, + "ctxt": 0 + }, + "stmts": [ + { + "type": "IfStatement", + "span": { + "start": 39, + "end": 837, + "ctxt": 0 + }, + "test": { + "type": "BooleanLiteral", + "span": { + "start": 43, + "end": 47, + "ctxt": 0 + }, + "value": true + }, + "consequent": { + "type": "BlockStatement", + "span": { + "start": 49, + "end": 837, + "ctxt": 0 + }, + "stmts": [ + { + "type": "IfStatement", + "span": { + "start": 59, + "end": 831, + "ctxt": 0 + }, + "test": { + "type": "BooleanLiteral", + "span": { + "start": 63, + "end": 67, + "ctxt": 0 + }, + "value": true + }, + "consequent": { + "type": "BlockStatement", + "span": { + "start": 69, + "end": 831, + "ctxt": 0 + }, + "stmts": [ + { + "type": "WhileStatement", + "span": { + "start": 83, + "end": 821, + "ctxt": 0 + }, + "test": { + "type": "Identifier", + "span": { + "start": 90, + "end": 94, + "ctxt": 0 + }, + "value": "test", + "typeAnnotation": null, + "optional": false + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 96, + "end": 821, + "ctxt": 0 + }, + "stmts": [ + { + "type": "IfStatement", + "span": { + "start": 114, + "end": 807, + "ctxt": 0 + }, + "test": { + "type": "Identifier", + "span": { + "start": 118, + "end": 122, + "ctxt": 0 + }, + "value": "test", + "typeAnnotation": null, + "optional": false + }, + "consequent": { + "type": "BlockStatement", + "span": { + "start": 124, + "end": 807, + "ctxt": 0 + }, + "stmts": [ + { + "type": "IfStatement", + "span": { + "start": 146, + "end": 789, + "ctxt": 0 + }, + "test": { + "type": "Identifier", + "span": { + "start": 150, + "end": 154, + "ctxt": 0 + }, + "value": "test", + "typeAnnotation": null, + "optional": false + }, + "consequent": { + "type": "BlockStatement", + "span": { + "start": 156, + "end": 789, + "ctxt": 0 + }, + "stmts": [ + { + "type": "IfStatement", + "span": { + "start": 182, + "end": 767, + "ctxt": 0 + }, + "test": { + "type": "Identifier", + "span": { + "start": 186, + "end": 190, + "ctxt": 0 + }, + "value": "test", + "typeAnnotation": null, + "optional": false + }, + "consequent": { + "type": "BlockStatement", + "span": { + "start": 192, + "end": 767, + "ctxt": 0 + }, + "stmts": [ + { + "type": "IfStatement", + "span": { + "start": 222, + "end": 741, + "ctxt": 0 + }, + "test": { + "type": "Identifier", + "span": { + "start": 226, + "end": 230, + "ctxt": 0 + }, + "value": "test", + "typeAnnotation": null, + "optional": false + }, + "consequent": { + "type": "BlockStatement", + "span": { + "start": 232, + "end": 741, + "ctxt": 0 + }, + "stmts": [ + { + "type": "WhileStatement", + "span": { + "start": 266, + "end": 711, + "ctxt": 0 + }, + "test": { + "type": "Identifier", + "span": { + "start": 273, + "end": 277, + "ctxt": 0 + }, + "value": "test", + "typeAnnotation": null, + "optional": false + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 279, + "end": 711, + "ctxt": 0 + }, + "stmts": [ + { + "type": "IfStatement", + "span": { + "start": 317, + "end": 677, + "ctxt": 0 + }, + "test": { + "type": "Identifier", + "span": { + "start": 321, + "end": 325, + "ctxt": 0 + }, + "value": "test", + "typeAnnotation": null, + "optional": false + }, + "consequent": { + "type": "BlockStatement", + "span": { + "start": 327, + "end": 677, + "ctxt": 0 + }, + "stmts": [ + { + "type": "IfStatement", + "span": { + "start": 369, + "end": 639, + "ctxt": 0 + }, + "test": { + "type": "Identifier", + "span": { + "start": 373, + "end": 377, + "ctxt": 0 + }, + "value": "asdf", + "typeAnnotation": null, + "optional": false + }, + "consequent": { + "type": "BlockStatement", + "span": { + "start": 379, + "end": 639, + "ctxt": 0 + }, + "stmts": [ + { + "type": "IfStatement", + "span": { + "start": 425, + "end": 597, + "ctxt": 0 + }, + "test": { + "type": "Identifier", + "span": { + "start": 429, + "end": 433, + "ctxt": 0 + }, + "value": "asdf", + "typeAnnotation": null, + "optional": false + }, + "consequent": { + "type": "BlockStatement", + "span": { + "start": 435, + "end": 597, + "ctxt": 0 + }, + "stmts": [ + { + "type": "ExpressionStatement", + "span": { + "start": 485, + "end": 551, + "ctxt": 0 + }, + "expression": { + "type": "AssignmentExpression", + "span": { + "start": 485, + "end": 550, + "ctxt": 0 + }, + "operator": "+=", + "left": { + "type": "Identifier", + "span": { + "start": 485, + "end": 489, + "ctxt": 0 + }, + "value": "test", + "typeAnnotation": null, + "optional": false + }, + "right": { + "type": "BinaryExpression", + "span": { + "start": 493, + "end": 550, + "ctxt": 0 + }, + "operator": "+", + "left": { + "type": "BinaryExpression", + "span": { + "start": 493, + "end": 535, + "ctxt": 0 + }, + "operator": "+", + "left": { + "type": "BinaryExpression", + "span": { + "start": 493, + "end": 526, + "ctxt": 0 + }, + "operator": "+", + "left": { + "type": "BinaryExpression", + "span": { + "start": 493, + "end": 508, + "ctxt": 0 + }, + "operator": "+", + "left": { + "type": "StringLiteral", + "span": { + "start": 493, + "end": 499, + "ctxt": 0 + }, + "value": " || ", + "hasEscape": false + }, + "right": { + "type": "ParenthesisExpression", + "span": { + "start": 502, + "end": 508, + "ctxt": 0 + }, + "expression": { + "type": "Identifier", + "span": { + "start": 503, + "end": 507, + "ctxt": 0 + }, + "value": "test", + "typeAnnotation": null, + "optional": false + } + } + }, + "right": { + "type": "StringLiteral", + "span": { + "start": 511, + "end": 526, + "ctxt": 0 + }, + "value": " === null || ", + "hasEscape": false + } + }, + "right": { + "type": "ParenthesisExpression", + "span": { + "start": 529, + "end": 535, + "ctxt": 0 + }, + "expression": { + "type": "Identifier", + "span": { + "start": 530, + "end": 534, + "ctxt": 0 + }, + "value": "test", + "typeAnnotation": null, + "optional": false + } + } + }, + "right": { + "type": "StringLiteral", + "span": { + "start": 538, + "end": 550, + "ctxt": 0 + }, + "value": " === '' ", + "hasEscape": true + } + } + } + } + ] + }, + "alternate": null + } + ] + }, + "alternate": null + } + ] + }, + "alternate": null + } + ] + } + } + ] + }, + "alternate": null + } + ] + }, + "alternate": null + } + ] + }, + "alternate": null + } + ] + }, + "alternate": null + } + ] + } + } + ] + }, + "alternate": null + } + ] + }, + "alternate": null + } + ] + }, + "generator": false, + "async": false, + "typeParameters": null, + "returnType": null + } + } + } + ], + "interpreter": null +} diff --git a/ecmascript/transforms/tests/fixer_test262.rs b/ecmascript/transforms/tests/fixer_test262.rs index e0dfc34b3bb..dc3d5adf758 100644 --- a/ecmascript/transforms/tests/fixer_test262.rs +++ b/ecmascript/transforms/tests/fixer_test262.rs @@ -25,6 +25,11 @@ const IGNORED_PASS_TESTS: &[&str] = &[ // TODO: uningnore "5654d4106d7025c2.js", "431ecef8c85d4d24.js", + // Stack size (Stupid parens) + "6b5e7e125097d439.js", + "714be6d28082eaa7.js", + "882910de7dd1aef9.js", + "dd3c63403db5c06e.js", // Generated code is better than it from `pass` "0da4b57d03d33129.js", "aec65a9745669870.js",