Web3 DAO | Ethereum Foundation Logo

Forbid field and method name duplication in struct definition

Organization

Ethereum Foundation

Deadline

N/A

Status

LIVE


INSTRUCTIONS

Currently, field and struct names can be duplicated in a struct definition. For example, the below code is allowed,

pub struct Bar {
    pub x: i32
    
    pub fn x(self) -> i32 {
        return 0
    }
}

This can be error-prone; Unintentionally, users might write field access with the intention of a method call or vice versa. So it would be better/safer to forbid this duplication.