diff --git a/es2panda/ir/expressions/callExpression.cpp b/es2panda/ir/expressions/callExpression.cpp index 96085be9abf3b5aae3ab14ebbf795f948895d79f..cc1963c9c7e2328303b78c411401b456ba3ec07f 100644 --- a/es2panda/ir/expressions/callExpression.cpp +++ b/es2panda/ir/expressions/callExpression.cpp @@ -180,7 +180,11 @@ void CallExpression::Compile(compiler::PandaGen *pg) const realCallee->Compile(pg); } - pg->StoreAccumulator(this, callee); + if (realCallee->IsMemberExpression()) { + pg->StoreAccumulator(realCallee->AsMemberExpression()->Property(), callee); + } else { + pg->StoreAccumulator(this, callee); + } pg->GetOptionalChain()->CheckNullish(optional_, callee); if (containsSpread) { @@ -202,6 +206,16 @@ void CallExpression::Compile(compiler::PandaGen *pg) const } if (hasThis) { + /* + * To obtain more accurate line number information in the MemberExpression scenario, + * bind CallThis to the property node instead of the entire callee. + * especially for cases involving async stack tracing. + */ + if (realCallee->IsMemberExpression()) { + pg->CallThis(realCallee->AsMemberExpression()->Property(), callee, + static_cast(arguments_.size() + 1)); + return; + } pg->CallThis(this, callee, static_cast(arguments_.size() + 1)); return; }