Misleading error message when trying to set type alias with proc from imported file
- Dominant language
- C++
- Stars
- 1.9k
- Forks
- 283
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 135
Description
**Describe the bug**
Trying to create type alias with imported proc causes cpp error.
**To Reproduce**
Steps to reproduce the behavior:
1. Write following code:
`foo.x`
```rust
pub proc p {
init {}
config() {}
next (tok: token, state: ()) {}
}
```
`bar.x`
```rust
import foo;
type y = foo::p;
```
2. Build it with bazel using following targets
```bazel
xls_dslx_library(
name = "foo_dslx",
srcs = ["foo.x"],
)
xls_dslx_library(
name = "bar_dslx",
srcs = ["bar.x"],
deps = [":foo_dslx"],
)
```
```sh
bazel build -- //:bar_dslx
```
3. See error
```none
ERROR: /.../xls/BUILD:68:17: Parsing and type checking DSLX source files of target bar_dslx failed: (Exit 255): bash failed:
error executing command (from target //:bar_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
E0516 11:55:27.188798 3 deduce.cc:743] INTERNAL: XLS_RET_CHECK failure (xls/dslx/type_system/deduce.cc:743) type.has_value() pub proc p {
config() {}
init {}
next(tok: token, state: ()) {}
}
0x6399afb4c7fa: xabsl::StatusBuilder::CreateStatusAndConditionallyLog()
0x6399adda25e9: absl::lts_20240116::StatusOr<>::StatusOr<>()
0x6399ade29b75: std::__1::__variant_detail::__visitation::__base::__dispatcher<>::__dispatch[abi:v170002]<>()
0x6399ade13bff: xls::dslx::(anonymous namespace)::DeduceVisitor::HandleColonRef()
0x6399ae1d24eb: xls::dslx::ColonRef::Accept()
0x6399ade0adaf: xls::dslx::Deduce()
0x6399addda5b5: std::__1::__function::__func<>::operator()()
0x6399adecf458: xls::dslx::DeduceCtx::Deduce()
0x6399ade0e984: xls::dslx::(anonymous namespace)::DeduceVisitor::HandleTypeRef()
0x6399ae1d233b: xls::dslx::TypeRef::Accept()
0x6399ade0adaf: xls::dslx::Deduce()
0x6399addda5b5: std::__1::__function::__func<>::operator()()
0x6399adecf458: xls::dslx::DeduceCtx::Deduce()
0x6399ade0fdd1: xls::dslx::(anonymous namespace)::DeduceVisitor::HandleTypeRefTypeAnnotation()
0x6399ae1d27fb: xls::dslx::TypeRefTypeAnnotation::Accept()
0x6399ade0adaf: xls::dslx::Deduce()
0x6399addda5b5: std::__1::__function::__func<>::operator()()
0x6399adecf458: xls::dslx::DeduceCtx::Deduce()
0x6399ade0e64d: xls::dslx::(anonymous namespace)::DeduceVisitor::HandleTypeAlias()
0x6399ae1d424b: xls::dslx::TypeAlias::Accept()
0x6399ade0adaf: xls::dslx::Deduce()
0x6399addda5b5: std::__1::__function::__func<>::operator()()
0x6399adecf458: xls::dslx::DeduceCtx::Deduce()
0x6399addd6ea7: xls::dslx::TypecheckModule()
0x6399add6aad7: xls::dslx::TypecheckModule()
0x6399add69fcc: xls::dslx::ParseAndTypecheck()
0x6399add5f065: xls::dslx::ParseAndTest()
0x6399add012b5: main
0x71469e1b8cd0: [unknown]
E0516 11:55:27.188847 3 command_line_utils.cc:45] Could not extract a textual position from error message: INTERNAL: XLS_RET_CHECK failure (xls/dslx/type_system/deduce.cc:743) type.has_value() pub proc p {
config() {}
init {}
next(tok: token, state: ()) {}
}: INVALID_ARGUMENT: Provided status is not in recognized error form: INTERNAL: XLS_RET_CHECK failure (xls/dslx/type_system/deduce.cc:743) type.has_value() pub proc p {
config() {}
init {}
next(tok: token, state: ()) {}
}
Error: INTERNAL: XLS_RET_CHECK failure (xls/dslx/type_system/deduce.cc:743) type.has_value() pub proc p {
config() {}
init {}
next(tok: token, state: ()) {}
Error parsing and type checking DSLX source file: bar.x
}Target //:bar_dslx failed to build
Use --verbose_failures to see the command lines of failed build steps.
```
**Expected behavior**
Resulting error should be the same as when trying to set type alias with proc from the same file:
```none
0007: type y = foo::p;
~~~~~~~~~~~~~~~^ ParseError: Expected a type, but identifier 'p' doesn't resolve to a type, it resolved to a NameDef
Error parsing and type checking DSLX source file: bar.x
Target //:bar_dslx failed to build
```
**Environment (this can be helpful for troubleshooting):**
- OS: Arch Linux x86_64
- Kernel version: 6.8.7-arch1-1
- XLS hash: `83d661222ba4c4b2a4ece64dd70d3f0061e4b0bf`
Contributor guide
Assessment
This issue has not been assessed yet.