Always generate code for .selector member access.

This commit is contained in:
Daniel Kirchner 2023-06-26 17:14:08 +02:00 committed by Kamil Śliwak
parent 64427412c4
commit 5c7214cbe3
3 changed files with 20 additions and 0 deletions

View File

@ -1,6 +1,7 @@
### 0.8.21 (unreleased) ### 0.8.21 (unreleased)
Important Bugfixes: Important Bugfixes:
* Code Generator: Always generate code for the expression in ``expression.selector``.
* Yul Optimizer: Fix ``FullInliner`` step (``i``) not preserving the evaluation order of arguments passed into inlined functions in code that is not in expression-split form (i.e. when using a custom optimizer sequence in which the step not preceded by ``ExpressionSplitter`` (``x``)). * Yul Optimizer: Fix ``FullInliner`` step (``i``) not preserving the evaluation order of arguments passed into inlined functions in code that is not in expression-split form (i.e. when using a custom optimizer sequence in which the step not preceded by ``ExpressionSplitter`` (``x``)).
@ -8,6 +9,7 @@ Language Features:
* Allow qualified access to events from other contracts. * Allow qualified access to events from other contracts.
* Relax restrictions on initialization of immutable variables. Reads and writes may now happen at any point at construction time outside of functions and modifiers. Explicit initialization is no longer mandatory. * Relax restrictions on initialization of immutable variables. Reads and writes may now happen at any point at construction time outside of functions and modifiers. Explicit initialization is no longer mandatory.
Compiler Features: Compiler Features:
* Commandline Interface: Add ``--ast-compact-json`` output in assembler mode. * 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: Add ``--ir-ast-json`` and ``--ir-optimized-ast-json`` outputs for Solidity input, providing AST in compact JSON format for IR and optimized IR.
@ -36,6 +38,7 @@ Bugfixes:
* Yul Optimizer: Fix ``FullInliner`` step not ignoring code that is not in expression-split form. * Yul Optimizer: Fix ``FullInliner`` step not ignoring code that is not in expression-split form.
* Yul Optimizer: Fix optimized IR being unnecessarily passed through the Yul optimizer again before bytecode generation. * Yul Optimizer: Fix optimized IR being unnecessarily passed through the Yul optimizer again before bytecode generation.
AST Changes: AST Changes:
* AST: Add the ``experimentalSolidity`` field to the ``SourceUnit`` nodes, which indicate whether the experimental parsing mode has been enabled via ``pragma experimental solidity``. * AST: Add the ``experimentalSolidity`` field to the ``SourceUnit`` nodes, which indicate whether the experimental parsing mode has been enabled via ``pragma experimental solidity``.

View File

@ -1659,6 +1659,10 @@ bool ExpressionCompiler::visit(MemberAccess const& _memberAccess)
{ {
if (functionType->hasDeclaration()) if (functionType->hasDeclaration())
{ {
// Still visit the expression in case it has side effects.
_memberAccess.expression().accept(*this);
utils().popStackElement(*functionType);
if (functionType->kind() == FunctionType::Kind::Event) if (functionType->kind() == FunctionType::Kind::Event)
m_context << u256(h256::Arith(util::keccak256(functionType->externalSignature()))); m_context << u256(h256::Arith(util::keccak256(functionType->externalSignature())));
else else

View File

@ -0,0 +1,13 @@
contract C {
uint x;
function f() public returns (uint256) {
h().f.selector;
return x;
}
function h() public returns (C) {
x = 42;
return this;
}
}
// ----
// f() -> 42