Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misleading error message when trying to set type alias with proc from imported file #1409

Open
m-torhan opened this issue May 16, 2024 · 0 comments
Labels
bug Something isn't working or is incorrect dslx DSLX (domain specific language) implementation / front-end

Comments

@m-torhan
Copy link

m-torhan commented May 16, 2024

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

pub proc p {
    init {}
    config() {}
    next (tok: token, state: ()) {}
}

bar.x

import foo;

type y = foo::p;
  1. Build it with bazel using following targets
xls_dslx_library(
    name = "foo_dslx",
    srcs = ["foo.x"],
)
xls_dslx_library(
    name = "bar_dslx",
    srcs = ["bar.x"],
    deps = [":foo_dslx"],
)
bazel build -- //:bar_dslx
  1. See error
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:

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
@proppy proppy added bug Something isn't working or is incorrect dslx DSLX (domain specific language) implementation / front-end labels May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working or is incorrect dslx DSLX (domain specific language) implementation / front-end
Projects
None yet
Development

No branches or pull requests

2 participants