google / google/xls

impl should support parametric methods

Open
#2,043 0 comments 0 reactions 0 assignees View on GitHub
bug dslx 🧦 sox
Dominant language
C++
Stars
1.9k
Forks
283
Avg merge
2d 10h
Merged PRs (30d)
135

Description

**Describe the bug**
It seems that parametric impl methods currently fails to typecheck.

**To Reproduce**
```
impl Foo {
fn new(size: u3) -> Self {
Foo {
size
}
}
fn is_valid_p(self: Self) -> bool {
self.size <= MAX_SIZE
}
}

fn foo() -> u3 {
Foo::new(u3:0).size
}

#[test]
fn foo_is_valid_test() {
let foo3 = Foo::new(u3:3);
assert_eq(foo3.is_valid_p(), true);
assert_eq(foo3.is_valid_p(), false);
}
```
fails to typecheck with the following error:
```
TypeInferenceError: Cannot resolve callee `foo3.is_valid_p` to a function; XLS_RET_CHECK failure (xls/dslx/type_system/deduce_utils.cc:696) colon_ref != nullptr ((nil) vs. nullptr)
```

**Expected behavior**
`is_valid_p` is resolved as a parametric method.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.