Inlining discards side effects in unused arguments

Open
#616 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

Start by locating the inlining pass and its tests for unused function arguments; the issue does not name specific files. Trace how arguments are handled when a parameter is unused, then add a regression test based on the example that checks the storage write is emitted exactly once before the return. Done means inlining preserves the argument's side effect while returning 7.

Written by the indexing model from the issue text.

Description

Inlining a function that ignores one parameter discards side effects in the corresponding argument. In this example, the storage write disappears from the generated code.

function writeSlot() returns (word) {
  assembly { sstore(0, 1) }
  return 0;
}
function second(a: word, b: word) returns (word) { return b; }
contract C {
  function main() returns (word) {
    return second(writeSlot(), 7);
  }
}

Actual: the emitted main contains only return 7; sstore(0, 1) has disappeared.
Expected: evaluate writeSlot() exactly once before returning 7, even though second does not use its first parameter. Inlining must preserve argument effects.

Dominant language
Haskell
Stars
115
Forks
11
Avg merge
20h 29m
Merged PRs (30d)
2

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

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/solcore

All issues in argotorg/solcore

Similar issues

More Haskell issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.