Skip to content

Commit

Permalink
IRGeneratorForStatements: Fix undefined order of functions when gener…
Browse files Browse the repository at this point in the history
…ating code for index expressions
  • Loading branch information
cameel committed Jul 11, 2023
1 parent b583e9e commit 8e426c7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Language Features:
* Allow qualified access to events from other contracts.

Compiler Features:
* Code Generator: Fix not entirely deterministic order of functions in unoptimized Yul output. The choice of C++ compiler in some cases would result in different (but equivalent) bytecode. Official binaries are affected.
* Commandline Interface: Add ``--ast-compact-json`` output in assembler mode.
* Commandline Interface: Add ``--ir-ast-json`` and ``--ir-optimized-ast-json`` outputs for Solidity input, providing AST in compact JSON format for IR and optimized IR.
* Commandline Interface: Respect ``--optimize-yul`` and ``--no-optimize-yul`` in compiler mode and accept them in assembler mode as well. ``--optimize --no-optimize-yul`` combination now allows enabling EVM assembly optimizer without enabling Yul optimizer.
Expand Down
14 changes: 7 additions & 7 deletions libsolidity/codegen/ir/IRGeneratorForStatements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2295,13 +2295,13 @@ void IRGeneratorForStatements::endVisit(IndexAccess const& _indexAccess)
}
case DataLocation::Memory:
{
string const memAddress =
m_utils.memoryArrayIndexAccessFunction(arrayType) +
"(" +
IRVariable(_indexAccess.baseExpression()).part("mpos").name() +
", " +
expressionAsType(*_indexAccess.indexExpression(), *TypeProvider::uint256()) +
")";
string const indexAccessFunction = m_utils.memoryArrayIndexAccessFunction(arrayType);
string const baseRef = IRVariable(_indexAccess.baseExpression()).part("mpos").name();
string const indexExpression = expressionAsType(
*_indexAccess.indexExpression(),
*TypeProvider::uint256()
);
string const memAddress = indexAccessFunction + "(" + baseRef + ", " + indexExpression + ")";

setLValue(_indexAccess, IRLValue{
*arrayType.baseType(),
Expand Down

0 comments on commit 8e426c7

Please sign in to comment.