ethereum/fe

Unexpected name conflict between a method and a function

Y-Nak opened this issue · 0 comments

Y-Nak commented

What is wrong?

When a method name is identical to another function that is defined outside of the struct, the compiler emits an invalid name conflict error.

pub fn ident(x: i32) -> i32 {
    return x
}


struct MyS {
    pub fn ident(self, x: i32) -> i32{
        return x
    }
}

error: function name `ident` conflicts with previously defined function
  ┌─ a.fe:1:8
  │
1 │ pub fn ident(x: i32) -> i32 {
  │        ^^^^^ `ident` first defined here
  ·
7 │     pub fn ident(self, x: i32) -> i32{
  │            ----- `ident` redefined here