Discuss warnings for accidental self-calls after function shadowing

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

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
57/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
haskell
Domain
compilers

Research direction

Start by reading the warning and name-resolution code that handles imported functions, method scopes, and self-calls; the issue does not name specific source files or tests. Reproduce the two-file example with all warnings enabled and check how the private method call is resolved. Done means the compiler warns about the accidental self-call while preserving the separate scopes allowed by PR #599.

Written by the indexing model from the issue text.

Description

A contract method can shadow an imported function and accidentally call itself without a warning. PR #599 intentionally permits these separate scopes; the silent self-call was reported in solcore-rs #48. This smaller example uses a private method and a runtime argument.

lib.sol:

export {setValue};
function setValue(x: word) {
  assembly { sstore(0, x) }
}

main.sol:

import {setValue} from lib;
contract C {
  function setValue(x: word) { setValue(x); }
  function main() {
    let x: word;
    assembly { x := calldataload(0) }
    setValue(x);
  }
}

Actual: compilation succeeds without a warning even with all warnings enabled. The runtime Hull contains the following method; the imported storage write is never reached:

function setValue (x : word) -> unit {
  setValue(x)
}
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.