diff --git a/es2panda/compiler/function/functionBuilder.cpp b/es2panda/compiler/function/functionBuilder.cpp index fda570ed4f975e4259a2850f25e0b0e43bcf32d2..088997deda709e735403c77ca1c5f333b28214ef 100644 --- a/es2panda/compiler/function/functionBuilder.cpp +++ b/es2panda/compiler/function/functionBuilder.cpp @@ -62,6 +62,11 @@ void FunctionBuilder::ImplicitReturn(const ir::AstNode *node) const } pg_->NotifyConcurrentResult(node); + if (node->Parent() && node->Parent()->IsScriptFunction() && + node->Parent()->AsScriptFunction()->IsGeneratedConstructor()) { + pg_->EmitReturn(node); + return; + } pg_->SetSourceLocationFlag(lexer::SourceLocationFlag::VALID_SOURCE_LOCATION); pg_->EmitReturn(node); } diff --git a/es2panda/ir/base/scriptFunction.h b/es2panda/ir/base/scriptFunction.h index f311f0d8da5af0447511e88e80eda4ea65a78ac6..f28d5859692c31cd1ba7e833d74a21453d910acb 100644 --- a/es2panda/ir/base/scriptFunction.h +++ b/es2panda/ir/base/scriptFunction.h @@ -151,6 +151,11 @@ public: (flags_ & ir::ScriptFunctionFlags::GENERATED_CONSTRUCTOR) != 0; } + bool IsGeneratedConstructor() const + { + return (flags_ & ir::ScriptFunctionFlags::GENERATED_CONSTRUCTOR) != 0; + } + bool IsStaticInitializer() const { return (flags_ & ir::ScriptFunctionFlags::STATIC_INITIALIZER) != 0;