File tree Expand file tree Collapse file tree 3 files changed +16
-5
lines changed Expand file tree Collapse file tree 3 files changed +16
-5
lines changed Original file line number Diff line number Diff line change 17
17
// SPDX-License-Identifier: GPL-3.0
18
18
19
19
#include < libsolidity/analysis/ControlFlowBuilder.h>
20
+ #include < libsolidity/ast/ASTUtils.h>
20
21
#include < libyul/AST.h>
21
22
#include < libyul/backends/evm/EVMDialect.h>
22
23
@@ -617,11 +618,7 @@ bool ControlFlowBuilder::visit(VariableDeclarationStatement const& _variableDecl
617
618
solAssert (tupleExpression->components ().size () > i, " " );
618
619
expression = tupleExpression->components ()[i].get ();
619
620
}
620
- while (auto tupleExpression = dynamic_cast <TupleExpression const *>(expression))
621
- if (tupleExpression->components ().size () == 1 )
622
- expression = tupleExpression->components ().front ().get ();
623
- else
624
- break ;
621
+ expression = resolveUnaryTuples (expression);
625
622
m_currentNode->variableOccurrences .emplace_back (
626
623
*var,
627
624
VariableOccurrence::Kind::Assignment,
Original file line number Diff line number Diff line change @@ -85,4 +85,14 @@ VariableDeclaration const* rootConstVariableDeclaration(VariableDeclaration cons
85
85
return rootDecl;
86
86
}
87
87
88
+ Expression const * resolveUnaryTuples (Expression const * _expr)
89
+ {
90
+ while (auto const * tupleExpression = dynamic_cast <TupleExpression const *>(_expr))
91
+ if (tupleExpression->components ().size () == 1 )
92
+ _expr = tupleExpression->components ().front ().get ();
93
+ else
94
+ break ;
95
+ return _expr;
96
+ }
97
+
88
98
}
Original file line number Diff line number Diff line change @@ -38,4 +38,8 @@ bool isConstantVariableRecursive(VariableDeclaration const& _varDecl);
38
38
// / Returns the innermost AST node that covers the given location or nullptr if not found.
39
39
ASTNode const * locateInnermostASTNode (int _offsetInFile, SourceUnit const & _sourceUnit);
40
40
41
+ // / @returns @a _expr itself, in case it is not an unary tuple expression. Otherwise it descends recursively
42
+ // / into unary tuples and returns the contained expression.
43
+ Expression const * resolveUnaryTuples (Expression const * _expr);
44
+
41
45
}
You can’t perform that action at this time.
0 commit comments