Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

referenced operator overloading do not work #15551

Open
Delta456 opened this issue Aug 26, 2022 · 1 comment
Open

referenced operator overloading do not work #15551

Delta456 opened this issue Aug 26, 2022 · 1 comment
Assignees
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@Delta456
Copy link
Member

V version: Latest commit
OS: WSL 2

What did you do?

struct Foo {
    f int
}

fn (f &Foo) + (f1 &Foo) &Foo {
    return &Foo{f:f.f+f1.f}
}
f := &Foo{2}
g := &Foo{3}
println(f + g)

What did you expect to see?

&Foo2{
   f: 5
}

What did you see instead?

main.v:10:9: error: invalid operator `+` to `&Foo` and `&Foo`
    8 | f := &Foo{2}
    9 | g := &Foo{3}
   10 | println(f + g)
      |         ~~~~~
   11 | 
   12 |
@Delta456 Delta456 added the Bug This tag is applied to issues which reports bugs. label Aug 26, 2022
@Delta456 Delta456 self-assigned this Aug 26, 2022
@Delta456
Copy link
Member Author

Delta456 commented Aug 26, 2022

Same for referenced generic operator overloading

struct Foo<T> {
    f T
}

fn (f &Foo<T>) + (f1 &Foo<T>) &Foo<T> {
    return &Foo<T>{f:f.f+f1.f}
}
f := &Foo<int>{2}
g := &Foo<int>{3}
println(f + g)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs.
Projects
None yet
Development

No branches or pull requests

1 participant