Skip to content

Commit da25d42

Browse files
committed
Assign debug data of literal as the debug data of the function itself.
1 parent 20b04be commit da25d42

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

libyul/optimiser/ConstantFunctionEvaluator.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,21 @@ void ConstantFunctionEvaluator::operator()(FunctionDefinition& _function)
9696
Block newBody;
9797
newBody.debugData = _function.body.debugData;
9898

99+
// After the execution, all debug data got swept away. To still maintain
100+
// useful information, we assign the literal debug data with the debug data
101+
// of the function itself.
102+
// One case this assignment is helpful is in the case of function with only
103+
// one return variable. In this case, it would likely be a solidity
104+
// constant.
105+
langutil::DebugData::ConstPtr literalDebugData = _function.debugData;
106+
99107
for (auto const& retVar: _function.returnVariables)
100108
{
101109
Identifier ident;
102110
ident.name = retVar.name;
103111

104112
Literal val;
113+
val.debugData = literalDebugData;
105114
val.kind = LiteralKind::Number;
106115
val.type = retVar.type;
107116
val.value = LiteralValue(interpreter.valueOfVariable(retVar.name));

0 commit comments

Comments
 (0)