google / xls

XLS: Accelerated HW Synthesis
http://google.github.io/xls/
Apache License 2.0
1.21k stars 179 forks source link

CHECK failure on unroll_for! without type annotation for index/accumulator #1702

Closed proppy closed 2 weeks ago

proppy commented 2 weeks ago

Describe the bug

A trivial unroll_for! expression seems to trigger a typechecking CHECK error.

To Reproduce

proc SomeProc {
  init { () }
  config() { }
  next(state: ()) {
    unroll_for! (i, a) in u32:0..u32:4 {
      a
    }(u32:0);
  }
}

will produce the following stacktrace:

absl::log_internal::LogMessage::Flush()
absl::log_internal::LogMessageFatal::~LogMessageFatal()
xls::dslx::(anonymous namespace)::DeduceVisitor::HandleUnrollFor()
xls::dslx::Deduce()
std::__u::__function::__policy_invoker<>::__call_impl<>()
xls::dslx::DeduceCtx::Deduce()
xls::dslx::(anonymous namespace)::DeduceVisitor::HandleStatement()
xls::dslx::Deduce()
std::__u::__function::__policy_invoker<>::__call_impl<>()
xls::dslx::DeduceCtx::Deduce()
xls::dslx::(anonymous namespace)::DeduceVisitor::HandleStatementBlock()
xls::dslx::Deduce()
std::__u::__function::__policy_invoker<>::__call_impl<>()
xls::dslx::DeduceCtx::Deduce()
xls::dslx::DeduceCtx::DeduceAndResolve()
xls::dslx::TypecheckFunction()
std::__u::__variant_detail::__visitation::__base::__dispatcher<>::__dispatch<>()
xls::dslx::TypecheckModule()
xls::dslx::ParseAndTypecheck()
xls::dslx::AbstractTestRunner::ParseAndTest()
xls::dslx::(anonymous namespace)::RealMain()

Expected behavior

An actionable error message if there is an actual type issue.