impl should recognize the concrete struct type as Self
- Dominant language
- C++
- Stars
- 1.9k
- Forks
- 283
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 135
Description
**Describe the bug**
Currently it seems that impl method only accept Self as the receiver type, should we support the concrete struct type as well?
**To Reproduce**
```
struct Params {
a: u32,
}
impl Params {
fn new(a: u32) -> Params {
Params {
a
}
}
fn b(self: Params) -> u32 {
self.a / u32:2
}
}
fn params() -> Params {
Params::new(u32:42)
}
#[test]
fn params_test() {
let p = params();
assert_eq(p.b(), u32:21);
}
```
produces the following error:
```
0023: fn params_test() {
0024: let p = params();
0025: assert_eq(p.b(), u32:21);
~~~~~~~~~~~~~~~~~~~~~^^ ArgCountMismatchError: Expected 1 parameter(s) but got 0 arguments.
0026: }
```
**Expected behavior**
```
fn b(self: Params) -> u32 {
```
get aliased to:
```
fn b(self: Self) -> u32 {
```
Contributor guide
Assessment
This issue has not been assessed yet.