google / google/xls

[DSLX:TIv2] Builtin parametrics of generic "type" do not unify

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

Description

**Describe the bug**
I tried for a while to fix this but want to document since I think I have to put it down for a bit -- the following crashes in IR conversion:

```
fn f() { assert_eq(1, u32:32) }
```

Because at IR conversion time it sees `u1`, `u32` in the type info -- this seems incorrect as TIv2 should be creating a single type variable for both operands that has constraints placed on it, since the signature is `(T, T) -> ()` i.e. the constraints to the LHS and RHS should be unified and the concretization would then be identical

Right now you get an error like:

```
libc++abi: terminating due to uncaught exception of type absl::lts_20250512::BadStatusOrAccess: Bad StatusOr access: INVALID_ARGUMENT: Could not build IR: Expected operand 1 of eq.5 to have type bits[1], has type bits[32].
Stack Trace:
0x1042af2f4: xls::BuilderBase::CreateBValue()
0x1042b9548: xls::BuilderBase::AddNode<>()
0x1042b6920: xls::BuilderBase::AddCompareOp()
0x1042b16e8: xls::BuilderBase::Eq()
0x102e8dae4: xls::dslx::FunctionConverter::HandleAssertEqBuiltin()
0x102e8f78c: xls::dslx::FunctionConverter::HandleInvocation()
0x102e7499c: xls::dslx::FunctionConverterVisitor::Visit()
0x102eb4b78: std::__1::__variant_detail::__visitation::__base::__dispatcher<>::__dispatch[abi:ne190102]<>()
0x102ea9834: xls::dslx::FunctionConverter::HandleStatement()
0x102e7499c: xls::dslx::FunctionConverterVisitor::Visit()
0x102ea9468: xls::dslx::FunctionConverter::HandleStatementBlock()
0x102e7499c: xls::dslx::FunctionConverterVisitor::Visit()
0x102e9f208: xls::dslx::FunctionConverter::HandleFunction()
0x102e6da1c: xls::dslx::(anonymous namespace)::ConvertCallGraph()
0x102e6c580: xls::dslx::ConvertModuleIntoPackage()
0x102e6eed0: xls::dslx::ConvertModuleToPackage()
0x102e5c70c: xls::dslx::AbstractTestRunner::ParseAndTest()
0x102e37490: main
0x19694ab98: start
```

cc @richmckeever

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.