argotorg / argotorg/solidity

Inconsistent rules for .address and .selector

Open
#10,905 12 comments 0 reactions 0 assignees View on GitHub
bug :bug: low impact medium effort
Dominant language
C++
Stars
25.7k
Forks
6.2k
Avg merge
2d 19h
Merged PRs (30d)
29

Description

## Description
Rules for deciding whether the code using `.address` or `.selector` on public functions is valid or not seem pretty random. It sometimes works without `this` and sometimes doesn't. Behavior is different between for `.selector` and for `.address`. It also changes depending on whether the value is actually used or not.

## Example
```solidity
contract B {
function g() public {}
}

contract C is B {
function h() public {
address a1 = g.address; // Error: Member "address" not found or not visible after argument-dependent lookup in function ().
address a2 = this.g.address;
address a3 = h.address; // Error: Member "address" not found or not visible after argument-dependent lookup in function ().
address a4 = this.h.address;

g.address; // Error: Expected identifier but got 'address'
this.g.address; // Error: Expected identifier but got 'address'
h.address; // Error: Expected identifier but got 'address'
this.h.address; // Error: Expected identifier but got 'address'

bytes4 s1 = g.selector;
bytes4 s2 = this.g.selector;
bytes4 s3 = h.selector; // Error: Member "selector" not found or not visible after argument-dependent lookup in function ().
bytes4 s4 = this.h.selector;

g.selector;
this.g.selector;
h.selector; // Error: Member "selector" not found or not visible after argument-dependent lookup in function ().
this.h.selector;
}
}
```

## Environment
- Compiler version: 0.8.1
- Operating system: Arch Linux

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue's contract example with Solidity 0.8.1 and compare diagnostics for .address and .selector with and without this, both when the value is used and unused. Then trace the compiler's member-access and semantic-analysis entry points; done requires an agreed, consistent rule and regression coverage for the reported cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, solidity
Domain
compilers
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.