crytic / crytic/slither

Overridden public function should not trigger external-function detector

Open
#501 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
6.4k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

Slither version 0.6.12

**`Foo.sol`:**
```solidity
1 | pragma solidity 0.6.8;
2 |
3 | import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
4 |
5 | contract Foo is Ownable {
6 | constructor() public Ownable() {}
7 |
8 | function renounceOwnership() public override onlyOwner {
9 | revert("ownership cannot be renounced");
10 | }
11 | }
```

**From `Ownable.sol`:**
```solidity
1 | function renounceOwnership() public virtual onlyOwner {
2 | emit OwnershipTransferred(_owner, address(0));
3 | _owner = address(0);
4 | }
```

**Expected:** Line 8 should not trigger `external-function` detector.

**Actual:** Line 8 triggers the `external-function` detector: (renounceOwnership() should be declared external)

Changing the overriding function's attribute from `public` to `external` causes compilation to fail with error `TypeError: Overriding function visibility differs.`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.