Internal error when struct param is used outside struct
- Dominant language
- C++
- Stars
- 1.9k
- Forks
- 283
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 135
Description
**Describe the bug**
When there is parametrized struct and its parameter's name is used somewhere outside the struct, then the internal error occurs. In such case I would expect some error that tells the definition was not found.
**To Reproduce**
Steps to reproduce the behavior:
1. Write following code
`foo.x`
```rust
struct Data {
a: uN[PARAM],
}
proc Foo {
config () {()}
init { }
next (state: ()) {
let test_val = Data { a: uN[PARAM]:1 };
}
}
```
2. Build DSLX library target
```bazel
xls_dslx_library(
name = "foo_dslx",
srcs = ["foo.x"],
deps = [],
)
```
```bash
bazel build //:foo_dslx
```
3. Observe internal error:
```none
ERROR: /.../google-xls/BUILD:76:17: Parsing and type checking DSLX source files of target foo_dslx failed: (Exit 255): bash
failed: error executing ParseAndTypeCheckDSLXSourceFile command (from target //:foo_dslx) /bin/bash -c ... (remaining 1 argument skipped)
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
E1125 13:29:46.901712 3 parametric_bind.cc:113] INTERNAL: XLS_RET_CHECK failure (xls/dslx/type_system/parametric_bind.cc:113) !actual_dim.IsParametric() PARAM
0x5e971b20bbca: xabsl::StatusBuilder::CreateStatusAndConditionallyLog()
0x5e97191afb89: xabsl::StatusBuilder::operator absl::lts_20240722::Status()
0x5e97192db22c: xls::dslx::ParametricBindTypeDim()
0x5e97192dbadc: xls::dslx::ParametricBind()
0x5e97192d3b13: xls::dslx::internal::ParametricInstantiator::InstantiateOneArg()
0x5e97192d8661: xls::dslx::internal::StructInstantiator::Instantiate()
0x5e97192d2aeb: xls::dslx::InstantiateStruct()
0x5e971929b79c: xls::dslx::DeduceStructInstance()
0x5e971926b86b: xls::dslx::(anonymous namespace)::DeduceVisitor::HandleStructInstance()
0x5e97197379fb: xls::dslx::StructInstance::Accept()
0x5e97192571c1: xls::dslx::Deduce()
0x5e971924ed45: std::__1::__function::__func<>::operator()()
0x5e9719355518: xls::dslx::DeduceCtx::Deduce()
0x5e97193562cc: xls::dslx::DeduceCtx::DeduceAndResolve()
0x5e971926730f: xls::dslx::(anonymous namespace)::DeduceVisitor::HandleLet()
0x5e97197385db: xls::dslx::Let::Accept()
0x5e97192571c1: xls::dslx::Deduce()
0x5e971924ed45: std::__1::__function::__func<>::operator()()
0x5e9719355518: xls::dslx::DeduceCtx::Deduce()
0x5e971925d8b4: xls::dslx::(anonymous namespace)::DeduceVisitor::HandleStatement()
0x5e971973843b: xls::dslx::Statement::Accept()
0x5e97192571c1: xls::dslx::Deduce()
0x5e971924ed45: std::__1::__function::__func<>::operator()()
0x5e9719355518: xls::dslx::DeduceCtx::Deduce()
0x5e97192625bb: xls::dslx::(anonymous namespace)::DeduceVisitor::HandleStatementBlock()
0x5e9719737cdb: xls::dslx::StatementBlock::Accept()
0x5e97192571c1: xls::dslx::Deduce()
0x5e971924ed45: std::__1::__function::__func<>::operator()()
0x5e9719355518: xls::dslx::DeduceCtx::Deduce()
0x5e97193562cc: xls::dslx::DeduceCtx::DeduceAndResolve()
0x5e971925410d: xls::dslx::TypecheckFunction()
0x5e971924b9cf: std::__1::__variant_detail::__visitation::__base::__dispatcher<>::__dispatch[abi:ue170006]<>()
0x5e971924a42d: xls::dslx::TypecheckModule()
0x5e97191d1507: xls::dslx::TypecheckModule()
0x5e97191d06aa: xls::dslx::ParseAndTypecheck()
0x5e97191c6660: xls::dslx::AbstractTestRunner::ParseAndTest()
0x5e9719149439: main
0x7cd290694e08: [unknown]
0x7cd290694ecc: __libc_start_main
0x5e9719147f65: _start
E1125 13:29:46.901783 3 command_line_utils.cc:50] Could not extract a textual position from error message: INTERNAL: XLS_RET_CHECK failure (xls/dslx/type_system/parametric_bind.cc:113) !actual_dim.IsParametric() PARAM: INVALID_ARGUMENT: Provided status is not in recognized error form: INTERNAL: XLS_RET_CHECK failure (xls/dslx/type_system/parametric_bind.cc:113) !actual_dim.IsParametric() PARAM
Error parsing and type checking DSLX source file: foo.x
Error: INTERNAL: XLS_RET_CHECK failure (xls/dslx/type_system/parametric_bind.cc:113) !actual_dim.IsParametric() PARAMTarget //:foo_dslx fai
led to build
```
**Expected behavior**
I would expect following error:
```none
foo.x:11:29-11:34
0009:
0010: next (state: ()) {
0011: let test_val = Data { a: uN[PARAM]:1 };
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^---^ ParseError: Cannot find a definition for name: "PARAM"
0012: }
0013: }
Error parsing and type checking DSLX source file: foo.x
Target //:foo_dslx failed to build
```
**Environment (this can be helpful for troubleshooting):**
- OS: Arch Linux x86_64
- Kernel version: 6.11.6-arch1-1
- XLS hash: fc06ae6cd2e9a23675afcaa43ecccc6cb7a1aa39
**Additional context**
When the parameter is removed from the struct, the internal error is not returned and instead there is the same error as in "Expected behavior".
Contributor guide
Assessment
This issue has not been assessed yet.