var can_inline = can_drop && compressor.option("inline") && !self.is_expr_pure(compressor);
if (can_inline && stat instanceof AST_Return) {
var value = stat.value;
- if (exp === fn && (!value || value.is_constant_expression() && safe_from_await_yield(value))) {
+ if (exp === fn && (!value || value.is_constant_expression()) && safe_from_await_yield(fn)) {
return make_sequence(self, convert_args(value)).optimize(compressor);
}
}
&& can_drop
&& all(fn.body, is_empty)
&& (fn === exp ? fn_name_unused(fn, compressor) : !has_default && !has_destructured && !fn.rest)
- && !(is_arrow(fn) && fn.value)) {
+ && !(is_arrow(fn) && fn.value)
+ && safe_from_await_yield(fn)) {
return make_sequence(self, convert_args()).optimize(compressor);
}
}
]
node_version: ">=10"
}
+
+issue_4769_1: {
+ options = {
+ side_effects: true,
+ }
+ input: {
+ console.log(function*() {
+ (function({} = yield => {}) {})();
+ }().next().done);
+ }
+ expect: {
+ console.log(function*() {
+ (function({} = yield => {}) {})();
+ }().next().done);
+ }
+ expect_stdout: "true"
+ node_version: ">=6"
+}
+
+issue_4769_2: {
+ options = {
+ inline: true,
+ }
+ input: {
+ console.log(function*() {
+ return function({} = yield => {}) {
+ return "PASS";
+ }();
+ }().next().value);
+ }
+ expect: {
+ console.log(function*() {
+ return function({} = yield => {}) {
+ return "PASS";
+ }();
+ }().next().value);
+ }
+ expect_stdout: "PASS"
+ node_version: ">=6"
+}