ICE when applying function call syntax to single element tuples containing comptime builtins, errors or events

Open
#17,111 6 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
cpp, solidity
Domain
compilers

Research direction

Start by reproducing the crash with the Solidity source in the issue, compiling with solc --bin and --bin --via-ir. Then inspect the mentioned ASTNode::referencedDeclaration usages and the listed paths in ASTUtils.cpp, ExpressionCompiler.cpp, and YulUtilFunctions::requireWithErrorFunction; done means the tuple-expression cases no longer trigger an internal compiler error across the shown examples and pipelines.

Written by the indexing model from the issue text.

Description

bug :bug: low effort low impact must have eventually should compile without error

Description

ASTNode::referencedDeclaration usages do not handle properly an argument passed to the function which is a tuple expression. In this case the function returns nullptr, but in a couple of places in the code there is an assets checking that the returned values is not null.

Environment

  • Compiler version: 0.8.37
  • Compilation pipeline (legacy, IR, SSA CFG): legacy, IR, maybe more
  • Target EVM version (as per compiler settings):
  • Framework/IDE (e.g. Foundry, Hardhat, Remix):
  • EVM execution environment / backend / blockchain client:
  • Operating system:

Steps to Reproduce

Run solc passing file below as na input and flag --bin or --bin --via-ir

// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.30;

library L {
    error E(uint256);
}

contract C {
    error E();
    error EU(uint256);

    // ASTUtils.cpp: erc7201CompileTimeValue
    function erc7201Paren() public pure returns (uint256) {
        return (erc7201)("abc");
    }

    function erc7201DoubleParen() public pure returns (uint256) {
        return ((erc7201))("abc");
    }

    // Legacy: ExpressionCompiler.cpp; IR: YulUtilFunctions::requireWithErrorFunction
    function requireParen(bool c) public pure {
        require(c, (E)());
    }

    function requireParenWithArgs(bool c) public pure {
        require(c, (EU)(1));
    }

    function requireDoubleParenWithArgs(bool c) public pure {
        require(c, ((EU))(2));
    }

    function requireParenMemberAccess(bool c) public pure {
        require(c, (L.E)(1));
    }
}

-->

Dominant language
C++
Stars
25.8k
Forks
6.2k
Avg merge
1d 22h
Merged PRs (30d)
43

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from argotorg/solidity

All issues in argotorg/solidity

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.