google / google/xls

RET_CHECK failure when reporting unused variable

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

Description

**Describe the bug**
As part of creating a repro for a separate issue, hit this ret check:

E1031 10:28:17.363165 1824 warn_on_defined_but_unused.cc:98] INTERNAL: XLS_RET_CHECK failure (xls/dslx/type_system/warn_on_defined_but_unused.cc:98) type.has_value() NameDef `result` 0x72e6bfe5e3a8 @ foo.x:6:21-6:27 parent kind `name definition tree` had no associated type information in type info 0x72e6bfe58118

**To Reproduce**
```
import std;

fn foo() -> u32 {
for (_, result): (u32, u32) in range(u32:0, u32:10) {
unroll_for! (j, result): (u32, u32) in range(u32:0, u32:10) {
for (k, result): (u32, u32) in range(u32:0, std::upow(u32:2, j)) {
k
}(result)
}(result)
}(u32:0)
}
```

**Expected behavior**
The most inner `result` should be gracefully reported as defined but unused.

**Additional context**
Full stack trace:

E1031 10:28:17.363165 1824 warn_on_defined_but_unused.cc:98] INTERNAL: XLS_RET_CHECK failure (xls/dslx/type_system/warn_on_defined_but_unused.cc:98) type.has_value() NameDef `result` 0x72e6bfe5e3a8 @ foo.x:6:21-6:27 parent kind `name definition tree` had no associated type information in type info 0x72e6bfe58118
=== Source Location Trace: ===
xls/common/status/status_builder.cc:197

0x55bd76f91341: xabsl::StatusBuilder::CreateStatusAndConditionallyLog()
0x55bd73e5982b: xls::dslx::WarnOnDefinedButUnused()
0x55bd73e1e806: xls::dslx::TypecheckFunction()
0x55bd73e1704e: xls::dslx::TypecheckModule()
0x55bd73db1d2d: xls::dslx::TypecheckModule()
0x55bd73db13ca: xls::dslx::ParseAndTypecheck()
0x55bd73da8bfc: xls::dslx::AbstractTestRunner::ParseAndTest()
0x55bd73d73cd9: main
0x7f08ebb433d4: __libc_start_main
0x55bd73d7202a: _start
E1031 10:28:17.363286 1824 command_line_utils.cc:50] Could not extract a textual position from error message: INTERNAL: XLS_RET_CHECK failure (xls/dslx/type_system/warn_on_defined_but_unused.cc:98) type.has_value() NameDef `result` 0x72e6bfe5e3a8 @ foo.x:6:21-6:27 parent kind `name definition tree` had no associated type information in type info 0x72e6bfe58118
=== Source Location Trace: ===
xls/common/status/status_builder.cc:197
xls/dslx/type_system/warn_on_defined_but_unused.cc:98
xls/dslx/type_system/typecheck_function.cc:256
xls/dslx/type_system/typecheck_module.cc:258
xls/dslx/parse_and_typecheck.cc:97
: INVALID_ARGUMENT: Provided status is not in recognized error form: INTERNAL: XLS_RET_CHECK failure (xls/dslx/type_system/warn_on_defined_but_unused.cc:98) type.has_value() NameDef `result` 0x72e6bfe5e3a8 @ foo.x:6:21-6:27 parent kind `name definition tree` had no associated type information in type info 0x72e6bfe58118
=== Source Location Trace: ===
xls/dslx/frontend/bindings.cc:55
Error: INTERNAL: XLS_RET_CHECK failure (xls/dslx/type_system/warn_on_defined_but_unused.cc:98) type.has_value() NameDef `result` 0x72e6bfe5e3a8 @ foo.x:6:21-6:27 parent kind `name definition tree` had no associated type information in type info 0x72e6bfe58118
=== Source Location Trace: ===
xls/common/status/status_builder.cc:197
xls/dslx/type_system/warn_on_defined_but_unused.cc:98
xls/dslx/type_system/typecheck_function.cc:256
xls/dslx/type_system/typecheck_module.cc:258
xls/dslx/parse_and_typecheck.cc:97
xls/dslx/interpreter_main.cc:199
Error parsing and type checking DSLX source file: foo.x

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.